Repository navigation
fix(deparser): keep AND CHAIN, trigger names, XML INDENT, SHOW quoting, COPY values, tablespaces and WITH TIES - #368
pyramation wants to merge 1 commit into
Conversation
…g, COPY values, tablespaces and WITH TIES
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟠 1 high · 🟡 1 medium 📍 Findings outside the diff (2) — 🟠 1 high · 🟡 1 medium — defects on lines GitHub can't attach comments to🟠 High — EXCLUDE constraint emits // packages/deparser/src/deparser.ts
3244 this.pushIndexConstraintOptions(node, output, context);
3245 if (node.where_clause) {
3246 output.push('WHERE');
3247 output.push(context.parens(this.visit(node.where_clause as any, context)));
3248 }The new 🟡 Medium — Trigger rename emits name before // packages/deparser/src/deparser.ts
8524 case 'OBJECT_TRIGGER':
8525 output.push('TRIGGER');
8526 if (node.subname) {
8527 output.push(QuoteUtils.quoteIdentifier(node.subname));
8528 }
8529 break;
8530 case 'OBJECT_TSCONFIGURATION':
8531 output.push('TEXT SEARCH CONFIGURATION');
8532 break;
8533 case 'OBJECT_TSDICTIONARY':
8534 output.push('TEXT SEARCH DICTIONARY');
8535 break;The new This PR extends
Reviewed commit: 8f032e0 |
|
Folded into #371 |
Summary
Fixes deparser paths that silently emitted different SQL (or invalid SQL) for valid PG18 input.
COMMIT AND CHAIN/ROLLBACK AND CHAINCOMMITCOMMIT AND CHAIN(TransactionStmt.chain)ALTER TRIGGER p ON grandp RENAME TO qALTER TRIGGER grandp RENAME TO q(syntax error)ALTER TRIGGER p ON grandp RENAME TO qXMLSERIALIZE(DOCUMENT x AS text INDENT)INDENTdroppedXmlSerialize.indent)SHOW "TimeZone"SHOW TimeZone(→timezone)QuoteUtils.quoteDottedName;SHOW ALLkeyed onname === 'all'soSHOW "ALL"stays quotedCOPY ... (FORMAT "CSV")FORMAT CSV(→csv)FORMAT 'CSV'Booleanfalse arg (JSON AST omitsboolval)HEADER(= true)HEADER falseCREATE TABLE ... TABLESPACE ts(incl. partitioned /PARTITION OF/USING heap)TABLESPACEdroppedCreateStmt.tablespacename)PRIMARY KEY/UNIQUE/EXCLUDE ... INCLUDE (b) WITH (fillfactor=10) USING INDEX TABLESPACE tsincluding,options,indexspace)ADD PRIMARY KEY USING INDEX "My Idx",CREATE/DROP/ALTER TABLESPACE "My TS"ALTER TABLESPACE ts SET (random_page_cost = 1)SET (RANDOM_PAGE_COST 1)(syntax error)SET (random_page_cost = 1)ORDER BY a FETCH FIRST 2 ROWS WITH TIES(also in views)LIMIT 2FETCH FIRST 2 ROWS WITH TIES; with an offset,OFFSET n ROWScomes first; a count that isn't a plain non-negative constant gets parenthesesTests
Each fix has a kitchen-sink fixture in
__fixtures__/kitchen-sink/misc/(mostly statements from the PG18 regression suite:transactions,triggers,xml,tablespace,limit), with generated tests fromnpm run kitchen-sink:transaction-chain,alter-trigger-rename,xmlserialize-indent,show-quoting,copy-option-values,tablespace-clauses,fetch-with-ties.The parser never produces a false
BooleanCOPY arg, so that case is a hand-built AST test in__tests__/misc/copy-boolean-options.test.ts.All 8 new suites fail with only
src/deparser.tsreverted:With the fix: deparser 758/758 tests and 424 snapshots pass (no existing snapshot changed). transform 250/250, plpgsql-deparser 115/115 and transform-ast 1443/1443 also pass.
Not changed: COPY's legacy
CSV HEADER/FREEZEproduceBoolean(true)args, which are still emitted as a bareHEADERinsideWITH (...). That means the same thing, but the reparsed AST has no arg.Link to Devin session: https://app.devin.ai/sessions/cb07c6509db64478af655f52611468f4
Open in Devin Desktop: https://app.devin.ai/desktop/session/cb07c6509db64478af655f52611468f4?variant=devin
Requested by: @pyramation