diff --git a/api/src/org/labkey/api/data/TableSelectorTestCase.java b/api/src/org/labkey/api/data/TableSelectorTestCase.java index 281681ebc2e..68d5c2ce623 100644 --- a/api/src/org/labkey/api/data/TableSelectorTestCase.java +++ b/api/src/org/labkey/api/data/TableSelectorTestCase.java @@ -17,6 +17,7 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Logger; import org.junit.Test; import org.labkey.api.collections.CsvSet; import org.labkey.api.data.Selector.ForEachBlock; @@ -30,6 +31,7 @@ import org.labkey.api.util.ExceptionUtil; import org.labkey.api.util.PageFlowUtil; import org.labkey.api.util.TestContext; +import org.labkey.api.util.logging.LogHelper; import org.springframework.jdbc.UncategorizedSQLException; import java.sql.ResultSet; @@ -50,6 +52,8 @@ public class TableSelectorTestCase extends AbstractSelectorTestCase { + private static final Logger LOG = LogHelper.getLogger(TableSelectorTestCase.class, "Test progress"); + @Test public void testTableSelector() throws SQLException { @@ -59,13 +63,25 @@ public void testTableSelector() throws SQLException // testTableSelector(DbSchema.get("oracle.granite", DbSchemaType.Bare).getTable("account"), Account.class); // Test MySQL or MariaDB database, if present - List mySqlScopes = Stream.of("mySql", "mariadb") - .map(DbScope::getDbScope).filter(Objects::nonNull).toList(); + List mySqlScopes = DbScope.getDbScopesToTest().stream() + .filter(scope -> Set.of("MySQL", "MariaDB").contains(scope.getSqlDialect().getProductName())) + .toList(); + for (DbScope mySqlScope: mySqlScopes) { DbSchema sakila = mySqlScope.getSchema("sakila", DbSchemaType.Bare); if (sakila.existsInDatabase()) - testTableSelector(sakila.getTable("country"), Country.class); + { + testTableSelector(sakila.getTable("Country"), Country.class); + } + else + { + DbSchema sys = mySqlScope.getSchema("sys", DbSchemaType.Bare); + if (sys.existsInDatabase()) + { + testTableSelector(sys.getTable("sys_config"), Config.class); + } + } } testTableSelector(CoreSchema.getInstance().getTableInfoActiveUsers(), User.class); testTableSelector(CoreSchema.getInstance().getTableInfoModules(), ModuleContext.class); @@ -124,6 +140,8 @@ public int hashCode() } } + record Config(String Variable, String Value, Date Set_Time, String Set_By){} + // public static class Account // { // private int _account_id; @@ -430,6 +448,9 @@ private void testColumnList(TableSelector selector, boolean stable) throws SQLEx private void testTableSelector(TableInfo table, Class clazz) throws SQLException { + DbSchema schema = table.getSchema(); + LOG.info("Testing {}.{}.{}", schema.getScope().getDisplayName(), schema.getName(), table.getName()); + TableSelector selector = new TableSelector(table); test(selector, clazz); diff --git a/api/src/org/labkey/api/data/dialect/StandardJdbcHelper.java b/api/src/org/labkey/api/data/dialect/StandardJdbcHelper.java index 986b0e0fa97..9362ddcde91 100644 --- a/api/src/org/labkey/api/data/dialect/StandardJdbcHelper.java +++ b/api/src/org/labkey/api/data/dialect/StandardJdbcHelper.java @@ -44,7 +44,7 @@ protected String parseDatabase(String url) throws ServletException if (-1 == dbEnd) dbEnd = url.length(); - // Last '/' is the database delimiter, except for "jdbc:postgresql:database" + // Last '/' is the database delimiter, except for "jdbc:postgresql:database" and old Oracle formats char dbDelimiter = url.contains("/") ? '/' : ':'; int dbDelimiterIndex = url.lastIndexOf(dbDelimiter, dbEnd);