Author: shawkins
Date: 2011-06-29 10:16:36 -0400 (Wed, 29 Jun 2011)
New Revision: 3291
Modified:
branches/7.4.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
Log:
TEIID-1662 fix for empty table types
Modified: branches/7.4.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
===================================================================
---
branches/7.4.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2011-06-29
01:10:22 UTC (rev 3290)
+++
branches/7.4.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2011-06-29
14:16:36 UTC (rev 3291)
@@ -1433,18 +1433,21 @@
// query string to be submitted to get table metadata info
StringBuffer sqlQuery = new StringBuffer(QUERY_TABLES);
- StringBuffer typesString = new StringBuffer("("); // criteria string
for different table types //$NON-NLS-1$
-
if (types != null) {
- // construct the criteria string
- for(int i=0; i < types.length; i++) {
- if (types[i] != null && types[i].length() > 0) {
- if (i > 0) {
- typesString.append(" OR "); //$NON-NLS-1$
- }
- typesString.append(TABLE_TYPE).append(LIKE_ESCAPE);
- }
- }
+ StringBuffer typesString = new StringBuffer("("); // criteria string
for different table types //$NON-NLS-1$
+ if (types.length == 0) {
+ typesString.append("1 = 0"); //$NON-NLS-1$
+ } else {
+ // construct the criteria string
+ for(int i=0; i < types.length; i++) {
+ if (types[i] != null && types[i].length() > 0) {
+ if (i > 0) {
+ typesString.append(" OR "); //$NON-NLS-1$
+ }
+ typesString.append(TABLE_TYPE).append(LIKE_ESCAPE);
+ }
+ }
+ }
typesString.append(")"); //$NON-NLS-1$
sqlQuery.append(" AND ").append(typesString.toString());
//$NON-NLS-1$
}
Modified:
branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
===================================================================
---
branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2011-06-29
01:10:22 UTC (rev 3290)
+++
branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2011-06-29
14:16:36 UTC (rev 3291)
@@ -615,6 +615,12 @@
ResultSet rs = dbmd.getTables(null, "SYSTEM",
"VIRTUALDATABASES", null); //$NON-NLS-1$ //$NON-NLS-2$
compareResultSet(rs);
}
+
+ @Test
+ public void testGetTables_noTypes() throws Exception {
+ ResultSet rs = dbmd.getTables(null, "SYSTEM",
"VIRTUALDATABASES", new String[0]); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse(rs.next());
+ }
@Test
public void testGetTables_specificTableTypes() throws Exception {
Show replies by date