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
{{ message }}
Repository navigation
deparser: ON DELETE SET NULL (column_list) loses its column list #349
pgsql-deparser drops the optional column list from ON DELETE SET NULL (...) and ON DELETE SET DEFAULT (...). The output is still valid SQL, but it means something different from the input — the referential action is silently widened from specific columns to all foreign key columns.
The column list on SET NULL / SET DEFAULT was added in PostgreSQL 15.
Versions
pgsql-deparser@18.3.6
plpgsql-parser@18.5.8
libpg-query@18.1.4
Node 24
Reproduction
import{parse}from'plpgsql-parser'import{deparse}from'pgsql-deparser'import{loadModule}from'libpg-query'awaitloadModule()constsql=`ALTER TABLE ONLY child ADD CONSTRAINT child_fk FOREIGN KEY (a, b) REFERENCES parent(a, b) ON DELETE SET NULL (b);`console.log(awaitdeparse((awaitparse(sql)).sql))
Expected
ALTERTABLE ONLY child ADD CONSTRAINT child_fk FOREIGN KEY (a, b) REFERENCES parent (a, b) ON DELETESETNULL (b);
Actual
ALTERTABLE ONLY child ADD CONSTRAINT child_fk FOREIGN KEY(a, b) REFERENCES parent (a, b) ON DELETESETNULL;
SET DEFAULT behaves the same way:
in : ... ON DELETE SET DEFAULT (b);
out: ... ON DELETE SET DEFAULT;
fk_del_set_cols is populated but does not appear to be consulted when rendering the ON DELETE clause.
Impact
This one is quiet — the output parses and applies cleanly, so nothing surfaces at apply time. The difference only shows up later, when a delete nulls more columns than the original schema intended.
Activity
Merge pull request #352 from constructive-io/fix/deparser-issues-292-…
pyramation commentedon Sep 17, 2026
thanks @jasdeepkhalsa for reporting sir!
pyramation commentedon Sep 17, 2026
thanks again!
#352 (comment)