Skip to content

#63 - Improve code coverage for other schemas #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -922,11 +922,11 @@ class UtplsqlDao {
* @param name test package name
* @return list of dependencies in the current schema
*/
def List<String> includes(String name) {
def List<String> includes(String owner, String name) {
val sql = '''
select referenced_name
select referenced_owner || '.' || referenced_name AS dep_name
from «IF dbaViewAccessible»dba«ELSE»all«ENDIF»_dependencies
WHERE owner = user
WHERE owner = upper(?)
AND name = upper(?)
AND referenced_owner NOT IN (
'SYS', 'SYSTEM', 'XS$NULL', 'OJVMSYS', 'LBACSYS', 'OUTLN', 'SYS$UMF',
Expand All @@ -940,7 +940,7 @@ class UtplsqlDao {
AND referenced_owner NOT LIKE 'APEX\_______'
AND referenced_type IN ('PACKAGE', 'TYPE', 'PROCEDURE', 'FUNCTION', 'TRIGGER')
'''
val deps = jdbcTemplate.queryForList(sql, String, #[name])
val deps = jdbcTemplate.queryForList(sql, String, #[owner, name])
return deps
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,21 @@ class UtplsqlController implements Controller {
}
}
}

def List<String> dependencies(String name, String connectionName) {
var List<String> ret = null
if (connectionName !== null) {
val owner = Connections.instance.getConnection(connectionName).schema
ret = dependencies(owner, name, connectionName)
}
return ret
}

def List<String> dependencies(String owner, String name, String connectionName) {
var List<String> ret = null
if (connectionName !== null) {
val dao = new UtplsqlDao(Connections.instance.getConnection(connectionName))
ret = dao.includes(name)
ret = dao.includes(owner, name)
}
return ret
}
Expand All @@ -328,12 +337,12 @@ class UtplsqlController implements Controller {
for (i : 0 ..< context.selection.length) {
val element = context.selection.get(i)
if (element instanceof PlSqlNode) {
val dep = dependencies(element.objectName, connectionName)
val dep = dependencies(element.owner, element.objectName, connectionName)
for (d : dep) {
ret.add(d)
}
} else if (element instanceof ChildObjectElement) {
val dep = dependencies(element.URL.memberObject, connectionName)
val dep = dependencies(element.URL.schema, element.URL.memberObject, connectionName)
for (d : dep) {
ret.add(d)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,10 @@ class DalTest extends AbstractJdbcTest {
END junit_utplsql_test_pkg;
''')
val dao = new UtplsqlDao(dataSource.connection)
val actualEmpty = dao.includes('TEST_F1')
val actualEmpty = dao.includes('SCOTT', 'TEST_F1')
Assert.assertEquals(#[], actualEmpty)
val actual = dao.includes('junit_utplsql_test_pkg')
Assert.assertEquals(#['JUNIT_UTPLSQL_TEST_PKG','JUNIT_F','UT_EXPECTATION'].sort, actual.sort)
val actual = dao.includes('SCOTT', 'junit_utplsql_test_pkg')
Assert.assertEquals(#['SCOTT.JUNIT_UTPLSQL_TEST_PKG','SCOTT.JUNIT_F','UT3_LATEST_RELEASE.UT_EXPECTATION'].sort, actual.sort)
}

@Test
Expand Down