diff --git a/api/src/org/labkey/api/data/DbScope.java b/api/src/org/labkey/api/data/DbScope.java index 022e7ef2870..5c8e1f2be51 100644 --- a/api/src/org/labkey/api/data/DbScope.java +++ b/api/src/org/labkey/api/data/DbScope.java @@ -591,7 +591,7 @@ private static LabKeyDataSource setPrimaryDataSource(Map driverClass) { try diff --git a/api/src/org/labkey/api/data/TableSelectorTestCase.java b/api/src/org/labkey/api/data/TableSelectorTestCase.java index 4d1969eea0b..075f9dcc500 100644 --- a/api/src/org/labkey/api/data/TableSelectorTestCase.java +++ b/api/src/org/labkey/api/data/TableSelectorTestCase.java @@ -38,84 +38,87 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Stream; -/** -* User: adam -* Date: 1/19/12 -* Time: 5:54 PM -*/ public class TableSelectorTestCase extends AbstractSelectorTestCase { @Test public void testTableSelector() throws SQLException { -// Calls below can be used to test that Oracle and MySQL dialects behave as expected, following our maxRows, offset, -// and other rules. Uncomment these lines and their corresponding bean classes below. + +// Call below can be used to test that Oracle dialect behaves as expected, following our maxRows, offset, and other +// rules. Uncomment this line and the corresponding bean class below. // testTableSelector(DbSchema.get("oracle.granite", DbSchemaType.Bare).getTable("account"), Account.class); -// testTableSelector(DbSchema.get("mySql.sakila", DbSchemaType.Bare).getTable("country"), Country.class); + + // Test MySQL database, if present + DbSchema sakila = DbSchema.get("mySql.sakila", DbSchemaType.Bare); + if (sakila.existsInDatabase()) + testTableSelector(sakila.getTable("country"), Country.class); testTableSelector(CoreSchema.getInstance().getTableInfoActiveUsers(), User.class); testTableSelector(CoreSchema.getInstance().getTableInfoModules(), ModuleContext.class); } -// public static class Country -// { -// private int _country_id; -// private String _country; -// private Date _last_update; -// -// public int getCountry_id() -// { -// return _country_id; -// } -// -// public void setCountry_id(int country_id) -// { -// _country_id = country_id; -// } -// -// public String getCountry() -// { -// return _country; -// } -// -// public void setCountry(String country) -// { -// _country = country; -// } -// -// public Date getLast_update() -// { -// return _last_update; -// } -// -// public void setLast_update(Date last_update) -// { -// _last_update = last_update; -// } -// -// @Override -// public boolean equals(Object o) -// { -// if (this == o) return true; -// if (o == null || getClass() != o.getClass()) return false; -// Country country = (Country) o; -// return _country_id == country._country_id && Objects.equals(_country, country._country) && Objects.equals(_last_update, country._last_update); -// } -// -// @Override -// public int hashCode() -// { -// return Objects.hash(_country_id, _country, _last_update); -// } -// } -// + @SuppressWarnings("unused") + public static class Country + { + private int _country_id; + private String _country; + private Date _last_update; + + public int getCountry_id() + { + return _country_id; + } + + public void setCountry_id(int country_id) + { + _country_id = country_id; + } + + public String getCountry() + { + return _country; + } + + public void setCountry(String country) + { + _country = country; + } + + public Date getLast_update() + { + return _last_update; + } + + public void setLast_update(Date last_update) + { + _last_update = last_update; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Country country = (Country) o; + return _country_id == country._country_id && Objects.equals(_country, country._country) && Objects.equals(_last_update, country._last_update); + } + + @Override + public int hashCode() + { + return Objects.hash(_country_id, _country, _last_update); + } + } + // public static class Account // { // private int _account_id; diff --git a/api/src/org/labkey/api/data/dialect/StandardJdbcHelper.java b/api/src/org/labkey/api/data/dialect/StandardJdbcHelper.java index f2355b6bb7e..8f452070a9c 100644 --- a/api/src/org/labkey/api/data/dialect/StandardJdbcHelper.java +++ b/api/src/org/labkey/api/data/dialect/StandardJdbcHelper.java @@ -44,12 +44,11 @@ protected String parseDatabase(String url) if (-1 == dbEnd) dbEnd = url.length(); - // Database name starts after the last '/' or ':' - int slash = url.lastIndexOf('/', dbEnd); - int colon = url.lastIndexOf(':', dbEnd); + // Last '/' is the database delimiter, except for "jdbc:postgresql:database" + char dbDelimiter = url.contains("/") ? '/' : ':'; + int dbDelimiterIndex = url.lastIndexOf(dbDelimiter, dbEnd); - int dbDelimiter = Math.max(slash, colon); - - return url.substring(dbDelimiter + 1, dbEnd); + // dbDelimiterIndex == 1 means no database name, so return empty string in that case + return dbDelimiterIndex != 1 ? url.substring(dbDelimiterIndex + 1, dbEnd) : ""; } } diff --git a/api/src/org/labkey/api/data/dialect/sqlKeywords.txt b/api/src/org/labkey/api/data/dialect/sqlKeywords.txt index 82cfb83bfc6..59fc0a37dbb 100644 --- a/api/src/org/labkey/api/data/dialect/sqlKeywords.txt +++ b/api/src/org/labkey/api/data/dialect/sqlKeywords.txt @@ -1,7 +1,7 @@ # A list of SQL keyword candidates -- all known and potential future keywords across all databases. We use this for testing. # Sources include the old, hard-coded keyword lists in the dialects, the reserved word lists in the PostgreSQL, MySQL, and # SQL Server documentation, and the return values of DatabaseMetaData.getSqlKeywords() for every database we support. -# Note: build is required after altering this file. +# Note: a build is required after altering this file. a abort abs @@ -241,6 +241,7 @@ degree delay_key_write delayed delete +delete_domain_id delimiter delimiters dense_rank @@ -281,6 +282,7 @@ dlurlscheme dlurlserver dlvalue do +do_domain_ids document domain double @@ -432,6 +434,7 @@ identity_insert identitycol if ignore +ignore_domain_ids ignore_server_ids ilike immediate @@ -749,6 +752,7 @@ p pack_keys pad page +page_checksum parallel parameter parameter_mode @@ -759,6 +763,7 @@ parameter_specific_name parameter_specific_schema parameters parse_gcol_expr +parse_vcol_expr parser partial partition @@ -851,6 +856,7 @@ redo_buffer_size redofile redundant ref +ref_system_id reference references referencing