fix(deparser): fix EXCLUDE WHERE, TypeName quoting, VALUES formatting; fix CI + pg-proto-parser#286
Merged
pyramation merged 16 commits intomainfrom Mar 15, 2026
Merged
Conversation
The deparser drops the WHERE clause from EXCLUDE USING ... WHERE (...) constraints. The parser correctly preserves where_clause in the AST, but the CONSTR_EXCLUSION handler in the deparser never outputs it. This causes partial exclusion constraints to lose their predicate during parse -> deparse cycles, which silently changes the constraint semantics.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
The pnpm --filter values must match the 'name' field in each package's package.json, not the directory name. Most packages were silently skipped because the filter matched nothing. Fixes: - deparser -> pgsql-deparser - parser -> pgsql-parser - pgsql-cli -> @pgsql/cli - proto-parser -> pg-proto-parser - transform -> @pgsql/transform - traverse -> @pgsql/traverse - utils -> @pgsql/utils
- Remove packages without test files: @pgsql/cli, @pgsql/traverse, @pgsql/utils - Add packages with tests that were missing: @pgsql/quotes - Add concurrency group to prevent push/pull_request runs from cancelling each other - All filter names now match package.json 'name' fields
…xisting failure) - push trigger now only fires on main branch (avoids duplicate runs on PR branches) - Removed pg-proto-parser from matrix (meta.test.ts has pre-existing failure) - pull_request + workflow_dispatch still trigger for all branches
- EXCLUDE WHERE clause: add where_clause output to CONSTR_EXCLUSION handler
- TypeName quoting: apply quoteIdentifierTypeName for single-name types (fixes "any", "AlertLevel", "C")
- Pretty VALUES formatting: keep tuples inline instead of expanding each value to its own line
- CREATE TYPE RANGE collation: fixed via TypeName quoting ("C" now properly quoted)
- CREATE AGGREGATE "any": fixed via TypeName quoting (reserved pseudo-type now quoted)
… cancelling other jobs
… @pgsql/types devDependency
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(deparser): fix EXCLUDE WHERE clause, TypeName quoting, VALUES formatting; fix CI + pg-proto-parser
Summary
1. Deparser bug fixes (5 bugs, 30 previously-failing tests)
Fixes five bugs in
packages/deparser/src/deparser.tsthat caused 30 test failures across 13 test suites. All were pre-existing onmainbut hidden because deparser tests never ran in CI (see CI fix below).Bug 1 — EXCLUDE WHERE clause dropped:
The
CONSTR_EXCLUSIONhandler never outputnode.where_clause. Given:The deparser silently dropped
WHERE (status = 'pending'), changing constraint semantics.Fix: Added
where_clauseoutput after the exclusions block (~line 3065).Bug 2 — TypeName single-name quoting missing:
Single-name types like
"AlertLevel","any","C"were emitted unquoted, producing invalid or semantically different SQL. For example,"any"(reserved pseudo-type) becameany(syntax error), and"AlertLevel"becameAlertLevel(case-insensitive, wrong semantics).Fix: Applied
QuoteUtils.quoteIdentifierTypeName()to single-name types in theTypeNamehandler (~line 1890). This also fixes the CREATE TYPE RANGE collation quoting issue (collation="C"→collation = "C").Bug 3 — Pretty VALUES tuple formatting:
Pretty-printed VALUES tuples were expanded to multi-line format even for single/short values:
Fix: Reverted to inline tuple formatting using
context.parens(values.join(', '))(~line 564-566).Related issue: #287
2. Fix CI test workflow
pnpm --filtermatchespackage.jsonnamefields, but the matrix used directory names. 7 of 9 packages silently skipped all tests. Onlyplpgsql-deparserandplpgsql-parserwere ever tested.pushandpull_requestevents fired for every PR commit. Fixed by restrictingpushtomainand adding aconcurrencygroup.fail-fast: falseso one package failure doesn't cancel other jobs.pg-proto-parserback to the matrix (has 9 test files; was previously removed).Final CI matrix (7 packages):
pgsql-deparserpgsql-deparserpgsql-parserpgsql-parserplpgsql-deparserplpgsql-deparserplpgsql-parserplpgsql-parserpg-proto-parserpg-proto-parser@pgsql/quotes@pgsql/quotes@pgsql/transform@pgsql/transform3. Fix pg-proto-parser test failures
meta.test.ts.snaphad an oldgoo.gl/fbAQLPlink that Jest 30 rejects. Updated tohttps://jestjs.io/docs/snapshot-testing.@pgsql/typesdevDependency: The test file importsSelectStmtfrom@pgsql/typesbut the package didn't declare it as a dependency. Added@pgsql/types@^17.6.2to devDependencies.All 9 pg-proto-parser test suites now pass (42 tests, 36 snapshots).
4. Test fixture additions
Added failing test case for EXCLUDE WHERE bug (
misc/issues-18.sql) and regenerated test scaffolding.Review & Testing Checklist for Human
quoteIdentifierTypeName()to ALL single-name types. This should only quote RESERVED_KEYWORD and lexically-unsafe identifiers (uppercase, special chars), but verify common types liketext,integer,uuid,jsonremain unquoted in deparsed output.Notes
pgsql-deparser,pgsql-parser,plpgsql-deparser,plpgsql-parser,pg-proto-parser,@pgsql/quotes,@pgsql/transformpg-proto-parserhad a pre-existing failure that is now fixed.constructive-db'sdatabase_transfertable, which usesEXCLUDE USING btree (database_id WITH =) WHERE (status = 'pending'). Thepgpm packagebundled SQL was missing the WHERE clause.Link to Devin run: https://app.devin.ai/sessions/3f7a5f172eff49b388c44b148691911c
Requested by: @pyramation