test: add regression tests for IMMUTABLE plpgsql functions with user-defined return types (#329)#332
test: add regression tests for IMMUTABLE plpgsql functions with user-defined return types (#329)#332
Conversation
…user-defined types (#329) Add two test cases to prevent regression of perpetual plan drift for IMMUTABLE plpgsql functions that return user-defined types (e.g. custom enums). The issue was reported against v1.6.2 but is already fixed in the current codebase by earlier normalization improvements. Test cases: - issue_329_immutable_udt_return: IMMUTABLE function returning custom enum - issue_329_immutable_udt_generated_col: same function used in GENERATED ALWAYS AS STORED column Fixes #329 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryAdds two regression test cases for issue #329 to prevent perpetual plan drift with IMMUTABLE plpgsql functions returning user-defined types. Test Coverage:
Both test cases follow the standard diff test pattern: Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 4bc9f01 |
There was a problem hiding this comment.
Pull request overview
Adds regression coverage for issue #329 to ensure pgschema plan remains idempotent for IMMUTABLE plpgsql functions that return user-defined types, including when referenced by generated columns.
Changes:
- Adds a no-op plan regression fixture for an
IMMUTABLEplpgsqlfunction returning a custom enum. - Adds a no-op plan regression fixture for the same function referenced by a
GENERATED ALWAYS AS STOREDcolumn. - Includes expected plan outputs across human (
plan.txt), SQL (plan.sql), and JSON (plan.json) formats for CLI/integration tests.
Reviewed changes
Copilot reviewed 8 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| testdata/diff/create_function/issue_329_immutable_udt_return/old.sql | Baseline schema defining enum + IMMUTABLE function returning UDT. |
| testdata/diff/create_function/issue_329_immutable_udt_return/new.sql | Target schema identical to old to assert no drift. |
| testdata/diff/create_function/issue_329_immutable_udt_return/plan.txt | Expected human output: no changes detected. |
| testdata/diff/create_function/issue_329_immutable_udt_return/plan.json | Expected JSON output for a no-op plan. |
| testdata/diff/create_function/issue_329_immutable_udt_return/plan.sql | Expected SQL output for a no-op plan (empty). |
| testdata/diff/create_function/issue_329_immutable_udt_return/diff.sql | Expected internal diff output for a no-op migration (empty). |
| testdata/diff/create_function/issue_329_immutable_udt_generated_col/old.sql | Baseline schema adds generated column referencing the function. |
| testdata/diff/create_function/issue_329_immutable_udt_generated_col/new.sql | Target schema identical to old to assert no drift and no planning error. |
| testdata/diff/create_function/issue_329_immutable_udt_generated_col/plan.txt | Expected human output: no changes detected. |
| testdata/diff/create_function/issue_329_immutable_udt_generated_col/plan.json | Expected JSON output for a no-op plan. |
| testdata/diff/create_function/issue_329_immutable_udt_generated_col/plan.sql | Expected SQL output for a no-op plan (empty). |
| testdata/diff/create_function/issue_329_immutable_udt_generated_col/diff.sql | Expected internal diff output for a no-op migration (empty). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
29c1b67- strip same-schema qualifiers innormalizeSchemaNames(issue Plan wants to change a column that hasn't changed. #283)0daf757- strip schema qualifiers from function/procedure bodies (issue Force qualified names in dump #252)Test cases added
issue_329_immutable_udt_return— IMMUTABLE plpgsql function returning a custom enum type (idempotency check: plan should detect no changes)issue_329_immutable_udt_generated_col— same function used in aGENERATED ALWAYS AS STOREDcolumn (verifies both function comparison and generated expression handling)Fixes #329
Test plan
PGSCHEMA_TEST_FILTER="create_function/issue_329" go test -v ./internal/diff -run TestDiffFromFiles— passesPGSCHEMA_TEST_FILTER="create_function/issue_329" go test -v ./cmd -run TestPlanAndApply— passes (including idempotency check)PGSCHEMA_TEST_FILTER="create_function/" go test -v ./cmd -run TestPlanAndApply— all 10 function tests pass🤖 Generated with Claude Code