You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
0 commit comments