Changeset: 163b784aa93b for monetdb-java URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=163b784aa93b Modified Files: ChangeLog src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java Branch: default Log Message:
Added full ordering to correct issues when retrieving columns from fks where a table has multiple fks to the same table. diffs (53 lines): diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ # This file is updated with Maddlog * Thu Jan 28 2021 Martin van Dinther <[email protected]> +- Corrected the ordering of the output of DatabaseMetaData methods + getImportedKeys(), getExportedKeys() and getCrossReference(). In cases + where a table would have multiple fks to the same external table, + the output was not as expected. This has been corrected, so the columns + now appear in the order as defined in the creation of the fks. + +* Thu Jan 28 2021 Martin van Dinther <[email protected]> - The dumping of table definitions from JdbcClient program has been improved. It now includes the ON UPDATE and ON DELETE rules for foreign key constraints. Also it no longer generates CREATE INDEX statements diff --git a/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java b/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java --- a/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @@ -2696,7 +2696,9 @@ public class MonetDatabaseMetaData } } - query.append(" ORDER BY \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\", \"KEY_SEQ\""); + // Note: the extra \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\" in the ordering is important + // else we do not get the correct column order when multiple fks exist to the same pk in 1 table or query multiple tables. + query.append(" ORDER BY \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\", \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"KEY_SEQ\""); return executeMetaDataQuery(query.toString()); } @@ -2779,7 +2781,9 @@ public class MonetDatabaseMetaData } } - query.append(" ORDER BY \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"KEY_SEQ\""); + // Note: the extra \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\" in the ordering is important + // else we do not get the correct column order when multiple fks exist to the same pk in 1 table or query multiple tables. + query.append(" ORDER BY \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\", \"KEY_SEQ\""); return executeMetaDataQuery(query.toString()); } @@ -2880,7 +2884,9 @@ public class MonetDatabaseMetaData } } - query.append(" ORDER BY \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"KEY_SEQ\""); + // Note: the extra \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\" in the ordering is important + // else we do not get the correct column order when multiple fks exist to the same pk in 1 table or query multiple tables. + query.append(" ORDER BY \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\", \"KEY_SEQ\""); return executeMetaDataQuery(query.toString()); } _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
