# HG changeset patch
# User Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
# Date 1566290463 -7200
# Node ID cf372fae2adba7393031c38ab470bb9689e6d884
# Parent  a91168efdf275c410764944cd4711ec3dd1552da
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.

diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
--- 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.