-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
read_schema
function for multi-column foreign key constaints (#476
) Update the query used by `read_schema` to fetch foreign key information. This fixes the problem of `columns` and `referencedColumns` containing duplicate entries for multi-column foreign keys. For a foreign key defined like `"fk_sellers" FOREIGN KEY (sellers_name, sellers_zip) REFERENCES sellers(name, zip)` the change in behaviour is as follows: Before: ```json { ... "foreignKeys": { "fk_sellers": { "name": "fk_sellers", "columns": [ "sellers_name", "sellers_zip", "sellers_name", "sellers_zip" ], "referencedTable": "sellers", "referencedColumns": [ "name", "zip", "name", "zip" ], "onDelete": "NO ACTION" } }, } ``` After: ```json { ... "foreignKeys": { "fk_sellers": { "name": "fk_sellers", "columns": [ "sellers_name", "sellers_zip" ], "referencedTable": "sellers", "referencedColumns": [ "name", "zip" ], "onDelete": "NO ACTION" } }, } ``` The solution here is to perform grouping and array aggregation of the referencing table's columns before the join to the referenced table's columns. Fixes #475
- Loading branch information
1 parent
96e50f9
commit 0b08a1d
Showing
2 changed files
with
109 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters