changeset 304:cf372fae2adb

Fixed outer join for retrieving indeces information. Also conditionally check to retrieve primary key indeces on getIndexInfo method. This should fix the failing Test_JdbcClient test.
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Tue, 20 Aug 2019 10:41:03 +0200 (2019-08-20)
parents a91168efdf27
children e74123be951f
files src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
@@ -3108,8 +3108,8 @@ public class MonetDatabaseMetaData
 		"JOIN \"sys\".\"schemas\" s ON t.\"schema_id\" = s.\"id\" " +
 		"JOIN \"sys\".\"objects\" o ON i.\"id\" = o.\"id\" " +
 		"JOIN \"sys\".\"columns\" c ON (t.\"id\" = c.\"table_id\" AND o.\"name\" = c.\"name\") " +
-		"LEFT OUTER JOIN \"sys\".\"keys\" k ON (i.\"name\" = k.\"name\" AND i.\"table_id\" = k.\"table_id\" AND k.\"type\" IN (0,1)) " +	// primary (0) and unique keys (1) only
-		"WHERE 1 = 1");
+		"LEFT OUTER JOIN \"sys\".\"keys\" k ON (i.\"name\" = k.\"name\" AND i.\"table_id\" = k.\"table_id\") " + 
+		"WHERE (k.\"type\" IS NULL OR k.\"type\" IN (1" + (unique ? "" : ",0") +  "))"); // primary keys are 0, unique keys are 1
 
 		if (catalog != null && !catalog.isEmpty()) {
 			// non-empty catalog selection.