Mercurial > hg > monetdb-java
changeset 827:b2cbe866d020
Enhanced DatabaseMetaData.getTables() method by adding support for SQL table type names: 'BASE TABLE', 'GLOBAL TEMPORARY' and 'LOCAL TEMPORARY' in parameter types[].
These are SQL synonyms of MonetDB table type names: 'TABLE', 'GLOBAL TEMPORARY TABLE' and 'LOCAL TEMPORARY TABLE'.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 20 Dec 2023 19:10:17 +0100 (15 months ago) |
parents | 1074ad1a4c63 |
children | be78e5a8c9cd |
files | ChangeLog src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java tests/JDBC_API_Tester.java |
diffstat | 3 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog file for monetdb-java # This file is updated with Maddlog +* Wed Dec 20 2023 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> +- Enhanced DatabaseMetaData.getTables() method by adding support for SQL + table type names: 'BASE TABLE', 'GLOBAL TEMPORARY' and 'LOCAL TEMPORARY' + in parameter types[]. These are SQL synonyms of MonetDB table type names: + 'TABLE', 'GLOBAL TEMPORARY TABLE' and 'LOCAL TEMPORARY TABLE'. + * Thu Dec 14 2023 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> - In ResultSet.getObject() method added support for retrieving TIMESTAMP WITH TIME ZONE data as java.time.OffsetDateTime object
--- a/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @@ -1932,12 +1932,26 @@ public final class MonetDatabaseMetaData if (types != null && types.length > 0) { query.append(needWhere ? "WHERE" : " AND").append(" tt.\"table_type_name\" IN ("); for (int i = 0; i < types.length; i++) { + String tabletype = types[i]; + /* Some JDBC applications use different table type names. + * Replace some SQL synonyms to valid MonetDB + * table type names as defined in sys.table_types */ + if ("BASE TABLE".equals(tabletype)) { + tabletype = "TABLE"; + } else + if ("GLOBAL TEMPORARY".equals(tabletype)) { + tabletype = "GLOBAL TEMPORARY TABLE"; + } else + if ("LOCAL TEMPORARY".equals(tabletype)) { + tabletype = "LOCAL TEMPORARY TABLE"; + } if (i > 0) { query.append(','); } - query.append('\'').append(types[i]).append('\''); + query.append('\'').append(tabletype).append('\''); } query.append(')'); + // for debug: System.out.println("SQL (len " + query.length() + "): " + query); } query.append(" ORDER BY \"TABLE_TYPE\", \"TABLE_SCHEM\", \"TABLE_NAME\"");
--- a/tests/JDBC_API_Tester.java +++ b/tests/JDBC_API_Tester.java @@ -1157,7 +1157,8 @@ final public class JDBC_API_Tester { "null jdbctst pk2c TABLE null null null null null null\n" + "null jdbctst pk_uc TABLE jdbctst.pk_uc table comment null null null null null\n"); - compareResultSet(dbmd.getTables(null, "tmp", "tlargechar", null), "getTables(null, tmp, tlargechar, null)", + String tabletypes[] = {"BASE TABLE", "LOCAL TEMPORARY", "GLOBAL TEMPORARY"}; + compareResultSet(dbmd.getTables(null, "tmp", "tlargechar", tabletypes), "getTables(null, tmp, tlargechar, tabletypes)", "Resultset with 10 columns\n" + "TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS TYPE_CAT TYPE_SCHEM TYPE_NAME SELF_REFERENCING_COL_NAME REF_GENERATION\n" + "char(1) varchar(1024) varchar(1024) varchar(25) varchar(1048576) char(1) char(1) char(1) char(1) char(1)\n" +