fix: normalize INTO clause whitespace + add OUT parameter test fixtures #281
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.
Summary
This PR adds test fixtures for OUT parameters with SELECT INTO multiple variables, and fixes a pretty-printing bug where the INTO clause insertion left weird whitespace.
Test Fixtures Added:
Bug Fix - Whitespace Normalization:
When PostgreSQL parses
SELECT ... INTO var FROM ..., it strips theINTO varbut leaves the original whitespace behind. This caused weird formatting like:The fix normalizes whitespace after INTO insertion:
Updates since last revision
packages/plpgsql-deparser/AGENTS.mddocumenting the complete workflow for adding test fixturesgenerated.jsonwith the new fixtures (now 192 fixtures total)deparser-fixes.test.tsfor the OUT parameters pattern (2 new snapshots)deparseExecSql()- this updates several existing snapshots whereFROMclauses now have consistent indentationReview & Testing Checklist for Human
plpgsql-deparser.ts(lines ~1488-1504) - verify the 4-space indent is appropriate and won't break existing consumershydrate-demo.test.ts.snap,schema-rename-mapped.test.ts.snap, andplpgsql-pretty.test.ts.snap- these show the formatting change impact on existing testsINTO id, user_id, access_token...ordering matching SELECT columnscd packages/plpgsql-deparser && pnpm testto confirm all 62 tests pass (192 fixtures round-trip)Recommended test plan: Parse and deparse a PL/pgSQL function with a long SELECT INTO clause, verify the FROM clause appears on a new line with reasonable indentation rather than excessive spacing.
Notes
This PR is part of a larger effort to support OUT parameters in constructive-db's auth functions. The TypeScript deparser already handles
PLpgSQL_row.fieldsfor the(unnamed row)case - these fixtures ensure that pattern continues to work correctly.Link to Devin run: https://app.devin.ai/sessions/f47b5a7894fa44548bb2fa47a647e0c3
Requested by: Dan Lynch (@pyramation)