-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Describe the bug
when a foreign key is defined within CREATE TABLE tablename ()
:
CONSTRAINT fk_order FOREIGN KEY (order_identifier) REFERENCES orders(order_id),
The column order_identifier
is not output in the results, so no way to know which column from the table is the referencing column. e.g., output:
"references": [
{
"table": "orders",
"columns": [
"order_id"
],
"schema": null,
"on_delete": null,
"on_update": null,
"deferrable_initially": null,
"constraint_name": "fk_order"
}
]
To Reproduce
Steps to reproduce the behavior (this example is using postgres as dialect):
- process file1.sql and view results and find alter in order_items table results. Column "name": "order_identifier" is present
sql = open('file1.sql', 'r').read()
results = parse_from_file(sql, group_by_type=True)
print(json.dumps(results, indent=2))
- process file2.sql and find constraints/references in order_items table results. Column "name": "order_identifier" is not present
sql = open('file2.sql', 'r').read()
results = parse_from_file(sql, group_by_type=True)
print(json.dumps(results, indent=2))
Expected behavior
to see similar results output from alter, where the name of referencing column is presented:
"alter": {
"columns": [
{
"name": "order_identifier",
"constraint_name": "fk_order",
"references": {
"table": "orders",
"schema": null,
"on_delete": null,
"on_update": null,
"deferrable_initially": null,
"column": "product_id"
}
}, ...
Screenshots
n/a
Desktop (please complete the following information):
- OS: macOS Monterey v12.6.1, Mac mini (M1, 2020)
- Browser: n/a
- Version:
- python == 3.9.6
- simple-ddl-parser == 0.30.0
Smartphone (please complete the following information):
- Device: n/a
- OS: n/a
- Browser: n/a
- Version: n/a
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
No labels