mirror of
https://github.com/safishamsi/graphify.git
synced 2026-07-12 18:37:12 +00:00
5d0392524a
The SQL parser (`extract_sql`) previously only extracted foreign key relationships defined inline within CREATE TABLE column definitions. FK constraints added via ALTER TABLE ... ADD CONSTRAINT ... FOREIGN KEY ... REFERENCES were silently ignored. Additionally, `_obj_name()` only read the first identifier child of object_reference nodes, so schema-qualified names like `Sales.Customer` were truncated to just `Sales`. Changes: - Add `alter_table` handler to `walk()` that extracts FK edges from ALTER TABLE ... ADD CONSTRAINT ... FOREIGN KEY ... REFERENCES - Fix `_obj_name()` to read the full object_reference text, preserving schema-qualified names (e.g. `Sales.Customer`) - Fix inline FK resolution in create_table and _walk_from_refs to use full object_reference text instead of first identifier only
13 lines
259 B
SQL
13 lines
259 B
SQL
CREATE TABLE customers (
|
|
id SERIAL PRIMARY KEY,
|
|
name TEXT NOT NULL
|
|
);
|
|
|
|
CREATE TABLE orders (
|
|
id SERIAL PRIMARY KEY,
|
|
customer_id INT,
|
|
total NUMERIC
|
|
);
|
|
|
|
ALTER TABLE orders ADD CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES customers(id);
|