fix: normalize INTO clause whitespace + add OUT parameter test fixtures#281
Merged
pyramation merged 6 commits intomainfrom Jan 23, 2026
Merged
Conversation
…bles Add Test 15 and Test 16 to exercise the pattern used in auth functions (sign_in, sign_up) where multiple OUT parameters are populated from a single SELECT statement. Test 15: OUT parameters with SELECT INTO multiple variables - Demonstrates plaintext token generation with hash storage - Uses uuid_generate_v5 for deterministic ID from token - SELECT INTO populates 6 OUT parameters from tokens table Test 16: OUT parameters with SELECT INTO STRICT - Tests STRICT modifier with multiple INTO targets
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:
|
- Add AGENTS.md documenting the proper workflow for adding test fixtures - Update generated.json with new fixtures for OUT parameters pattern - Test 15: OUT parameters with SELECT INTO multiple variables - Test 16: OUT parameters with SELECT INTO STRICT
… variables Add explicit test cases to deparser-fixes.test.ts for: - SELECT INTO multiple OUT parameters (auth function pattern) - SELECT INTO STRICT with multiple OUT parameters These tests generate snapshots to verify the deparser correctly handles PLpgSQL_row.fields for multiple INTO targets.
When the parser strips 'INTO <target>' from a SELECT statement, it leaves behind the original whitespace. This caused weird formatting like: SELECT x INTO y FROM z Now we normalize the whitespace: - If original had newlines, use newline + 4-space indent - If original was just spaces/tabs, collapse to single space This fixes the pretty-printing issue with long INTO target lists.
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.
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)