Mercurial > hg > monetdb-java
diff src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @ 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 (16 months ago) |
parents | 23f84ff380c2 |
children | e890195256ac |
line wrap: on
line diff
--- 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\"");