Merged
Conversation
This adds a new package for deparsing PL/pgSQL function ASTs back to SQL strings. The PL/pgSQL AST is different from the regular SQL AST and represents the internal structure of PL/pgSQL function bodies. Supported constructs: - Variable declarations (DECLARE section) - Control flow (IF, CASE, LOOP, WHILE, FOR, FOREACH) - Exception handling (BEGIN...EXCEPTION...END) - Cursor operations (OPEN, FETCH, CLOSE) - Return statements (RETURN, RETURN NEXT, RETURN QUERY) - Dynamic SQL (EXECUTE) - RAISE statements - And more... The deparser follows the same patterns as the existing pgsql-deparser package.
…rser - Add @libpg-query/parser as dev dependency for parsing PL/pgSQL - Create test-utils with fixture pipeline that loads from __fixtures__/plpgsql/ - Add jest.config.js for TypeScript support in tests - Update tests to use real parser output instead of hardcoded JSON fixtures - Tests now demonstrate proven pipeline: SQL fixtures -> parser -> deparser
- Add make-fixtures.ts script that generates fixtures from __fixtures__/plpgsql/ - Create generated.json with 176 valid PL/pgSQL statements (full SQL statements) - Add comprehensive test-utils with cleanPlpgsqlTree for AST comparison - Implement expectAstMatch for round-trip testing (parse -> deparse -> reparse) - Add FixtureTestUtils class for loading and running fixture tests - Update tests to use generated.json with proper round-trip validation - Add 'fixtures' npm script to package.json
…ests - Fix CALL statement deparser to avoid duplicate CALL keyword - Improve loop variable detection to only exclude implicitly declared vars (variables where lineno matches the loop statement's lineno) - Add plpgsql-pretty fixtures folder with sample SQL files - Add PlpgsqlPrettyTest utility for snapshot testing - Add snapshot tests for uppercase/lowercase formatting
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.
No description provided.