From cc76849844029d967d5dffc2b1ff6df182c68b88 Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Sat, 13 Jul 2019 11:41:23 +0200 Subject: [PATCH 1/3] change to snapshot version 1.1.0-SNAPSHOT --- sqldev/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqldev/pom.xml b/sqldev/pom.xml index ad4c3b18..ac802062 100644 --- a/sqldev/pom.xml +++ b/sqldev/pom.xml @@ -5,7 +5,7 @@ org.utplsql org.utplsql.sqldev - 1.0.0 + 1.1.0-SNAPSHOT bundle UTF-8 From 4b2e3ac2bd030a6485354bff8277241e1b40b570 Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Sat, 13 Jul 2019 11:44:50 +0200 Subject: [PATCH 2/3] getUtPlsqlVersion does not fail when utplsql is not installed returns a version null in this case, which is later converted to 0.0.0, which is not a supported version for this extension and not a supported version for the realtime reporter, hence calling the runner leads to a use of the worksheet runner regardless of the utPLSQL configuration. --- .../org/utplsql/sqldev/dal/UtplsqlDao.xtend | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.xtend b/sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.xtend index d0768738..71f7b8c6 100644 --- a/sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.xtend +++ b/sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.xtend @@ -33,6 +33,7 @@ import org.utplsql.sqldev.model.ut.OutputLines class UtplsqlDao { public static val UTPLSQL_PACKAGE_NAME = "UT" + public static val NOT_INSTALLED = 0000000 public static val FIRST_VERSION_WITH_INTERNAL_ANNOTATION_API = 3000004 public static val FIRST_VERSION_WITH_ANNOTATION_API = 3001003 public static val FIRST_VERSION_WITHOUT_INTERNAL_API = 3001008 @@ -60,14 +61,15 @@ class UtplsqlDao { * returns a normalized utPLSQL version in format 9.9.9 */ def String normalizedUtPlsqlVersion() { - val p = Pattern.compile("(\\d+\\.\\d+\\.\\d+)") val version = getUtPlsqlVersion() - val m = p.matcher(version) - if (m.find) { - return m.group(0) - } else { - return "0.0.0" + if (version !== null) { + val p = Pattern.compile("(\\d+\\.\\d+\\.\\d+)") + val m = p.matcher(version) + if (m.find) { + return m.group(0) + } } + return "0.0.0" } /** @@ -97,14 +99,20 @@ class UtplsqlDao { ? := ut.version; END; ''' - cachedUtPlsqlVersion = jdbcTemplate.execute(sql, new CallableStatementCallback() { - override String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException { - cs.registerOutParameter(1, Types.VARCHAR); - cs.execute - val version = cs.getString(1) - return version - } - }) + try { + cachedUtPlsqlVersion = jdbcTemplate.execute(sql, new CallableStatementCallback() { + override String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException { + cs.registerOutParameter(1, Types.VARCHAR); + cs.execute + val version = cs.getString(1) + return version + } + }) + } catch (SQLException e) { + // ignore error + } catch (DataAccessException e) { + // ignore error + } } return cachedUtPlsqlVersion } From 66be251c4b7ba196be46151a8b13e8711d67b0c1 Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Sat, 13 Jul 2019 11:46:39 +0200 Subject: [PATCH 3/3] testing if normalizedUtPlsqlVersion returns a not null value This test should succeed on a database without having utplsql installed. However, the test suite is not enhanced to work against a database without utplsql, that's simply not worth the effort. --- .../test/java/org/utplsql/sqldev/test/dal/DalTest.xtend | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalTest.xtend index 25573974..59b83072 100644 --- a/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalTest.xtend +++ b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalTest.xtend @@ -588,5 +588,12 @@ class DalTest extends AbstractJdbcTest { Assert.assertEquals("PACKAGE", actual) jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg") } + + @Test + def void normalizedUtPlsqlVersion() { + val dao = new UtplsqlDao(dataSource.connection) + val version = dao.normalizedUtPlsqlVersion + Assert.assertTrue(version !== null) + } } \ No newline at end of file