Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @ 421:163b784aa93b
Added full ordering to correct issues when retrieving columns from fks where a table has multiple fks to the same table.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 28 Jan 2021 21:59:38 +0100 (2021-01-28) |
parents | 50e43af49d47 |
children | 95d15f1d750d |
comparison
equal
deleted
inserted
replaced
420:a0f99a81ce8e | 421:163b784aa93b |
---|---|
2694 if (table != null && !table.equals("%")) { | 2694 if (table != null && !table.equals("%")) { |
2695 query.append(" AND fktable.\"name\" ").append(composeMatchPart(table)); | 2695 query.append(" AND fktable.\"name\" ").append(composeMatchPart(table)); |
2696 } | 2696 } |
2697 } | 2697 } |
2698 | 2698 |
2699 query.append(" ORDER BY \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\", \"KEY_SEQ\""); | 2699 // Note: the extra \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\" in the ordering is important |
2700 // else we do not get the correct column order when multiple fks exist to the same pk in 1 table or query multiple tables. | |
2701 query.append(" ORDER BY \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\", \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"KEY_SEQ\""); | |
2700 | 2702 |
2701 return executeMetaDataQuery(query.toString()); | 2703 return executeMetaDataQuery(query.toString()); |
2702 } | 2704 } |
2703 | 2705 |
2704 /** | 2706 /** |
2777 if (table != null && !table.equals("%")) { | 2779 if (table != null && !table.equals("%")) { |
2778 query.append(" AND pktable.\"name\" ").append(composeMatchPart(table)); | 2780 query.append(" AND pktable.\"name\" ").append(composeMatchPart(table)); |
2779 } | 2781 } |
2780 } | 2782 } |
2781 | 2783 |
2782 query.append(" ORDER BY \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"KEY_SEQ\""); | 2784 // Note: the extra \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\" in the ordering is important |
2785 // else we do not get the correct column order when multiple fks exist to the same pk in 1 table or query multiple tables. | |
2786 query.append(" ORDER BY \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\", \"KEY_SEQ\""); | |
2783 | 2787 |
2784 return executeMetaDataQuery(query.toString()); | 2788 return executeMetaDataQuery(query.toString()); |
2785 } | 2789 } |
2786 | 2790 |
2787 /** | 2791 /** |
2878 if (ftable != null && !ftable.equals("%")) { | 2882 if (ftable != null && !ftable.equals("%")) { |
2879 query.append(" AND fktable.\"name\" ").append(composeMatchPart(ftable)); | 2883 query.append(" AND fktable.\"name\" ").append(composeMatchPart(ftable)); |
2880 } | 2884 } |
2881 } | 2885 } |
2882 | 2886 |
2883 query.append(" ORDER BY \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"KEY_SEQ\""); | 2887 // Note: the extra \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\" in the ordering is important |
2888 // else we do not get the correct column order when multiple fks exist to the same pk in 1 table or query multiple tables. | |
2889 query.append(" ORDER BY \"FKTABLE_SCHEM\", \"FKTABLE_NAME\", \"FK_NAME\", \"PKTABLE_SCHEM\", \"PKTABLE_NAME\", \"PK_NAME\", \"KEY_SEQ\""); | |
2884 | 2890 |
2885 return executeMetaDataQuery(query.toString()); | 2891 return executeMetaDataQuery(query.toString()); |
2886 } | 2892 } |
2887 | 2893 |
2888 /** | 2894 /** |