test(plpgsql-deparser): add schema transform demo test with fixture-based snapshots#268
Merged
pyramation merged 2 commits intomainfrom Jan 6, 2026
Merged
Conversation
Demonstrates the heterogeneous AST transformation pipeline: - Parse SQL containing PL/pgSQL functions - Hydrate embedded SQL expressions into AST nodes - Traverse and transform schema names in both outer SQL AST and embedded SQL - Dehydrate back to strings - Deparse to final SQL output Includes 4 test cases: - Simple function with schema-qualified table reference - Trigger function with INSERT into schema-qualified table - RETURN QUERY function with schema-qualified table - Function calls inside PL/pgSQL expressions
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:
|
Adds comprehensive schema rename testing with: - SQL fixture file with 12 complex procedures covering various patterns (SELECT, INSERT, UPDATE, DELETE, RETURN QUERY, CTEs, subqueries, etc.) - Snapshot test that tracks all schema references found during traversal - Snapshot of final transformed SQL output The rename map snapshot shows 41 total references across 3 schemas: - app_public: 39 references (functions, tables, relations, func_calls) - app_private: 1 reference - app_internal: 1 reference All references are correctly transformed in the output SQL.
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.
test(plpgsql-deparser): add schema transform demo test with fixture-based snapshots
Summary
Adds demonstration tests showing how to use the heterogeneous AST transformation pipeline for schema renaming in PL/pgSQL functions. The tests demonstrate the full pipeline:
Two test files are included:
schema-transform.demo.test.ts- 4 inline test cases covering common patterns (simple SELECT, trigger INSERT, RETURN QUERY, function calls in expressions)schema-rename-mapped.test.ts- Fixture-based snapshot test that:__fixtures__/plpgsql/plpgsql_schema_rename.sql(12 complex procedures)The rename map snapshot shows 41 total references across 3 schemas:
app_public: 39 references (functions, tables, relations, func_calls)app_private: 1 referenceapp_internal: 1 referenceReview & Testing Checklist for Human
walk()APIs - the demo uses manual recursion for clarity but production code may want to use the existing infrastructureexpect(output).not.toMatch(/\bapp_public\./)is the right approach for avoiding substring false positives (e.g., "myapp_public" contains "app_public")Test plan:
Notes
__fixtures__/plpgsql/so it can be incorporated into generated tests