Skip to content

Commit

Permalink
When querying unique constraints metadata include new type 3 (= Uniqu…
Browse files Browse the repository at this point in the history
…e Key With Nulls Not Distinct).
  • Loading branch information
mvdvm committed Dec 12, 2024
1 parent 6b11bfa commit 40c36ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/monetdb/util/MDBvalidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private void validateUniqueness(
// fetch the primary or unique key info from the MonetDB system tables
final StringBuilder sb = new StringBuilder(400);
sb.append(" FROM sys.keys k JOIN sys.tables t ON k.table_id = t.id JOIN sys.schemas s ON t.schema_id = s.id"
+ " WHERE k.\"type\" = ").append(pkey ? 0 : 1) // 0 = primary keys, 1 = unique keys
+ " WHERE k.\"type\" ").append(pkey ? "= 0" : "IN (1,3)") // 0 = Primary Key, 1 = Unique Key, 3 = Unique Key With Nulls Not Distinct
.append(" and s.name = '").append(schema).append('\'');
String qry = sb.toString();
final int count = runCountQuery(qry);
Expand All @@ -291,7 +291,7 @@ private void validateUniqueness(
// fetch the primary or unique key info including columns from the MonetDB system tables
sb.append("SELECT s.name as sch_nm, t.name as tbl_nm, k.name as key_nm, o.name as col_nm, o.nr")
.append(" FROM sys.keys k JOIN sys.objects o ON k.id = o.id JOIN sys.tables t ON k.table_id = t.id JOIN sys.schemas s ON t.schema_id = s.id"
+ " WHERE k.\"type\" = ").append(pkey ? 0 : 1) // 0 = primary keys, 1 = unique keys
+ " WHERE k.\"type\" ").append(pkey ? "= 0" : "IN (1,3)") // 0 = Primary Key, 1 = Unique Key, 3 = Unique Key With Nulls Not Distinct
.append(" and s.name = '").append(schema).append('\'')
.append(" ORDER BY t.name, k.name, o.nr;");
qry = sb.toString();
Expand Down

0 comments on commit 40c36ee

Please sign in to comment.