Conversation
… dump (#252) Function and procedure bodies retained schema-qualified references (e.g., public.users) while table definitions were dumped unqualified, causing inconsistency for downstream tools like sqlc that parse SQL statically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses inconsistency in schema qualification between table definitions and function/procedure bodies in dump output. While table definitions are dumped without schema qualifiers, function and procedure bodies retained schema-qualified references (e.g., public.users), which created issues for downstream tools like sqlc that parse SQL statically.
Changes:
- Added
stripSchemaPrefixFromBodyfunction to strip the current schema qualifier from function/procedure bodies during IR normalization - Updated existing test fixtures to reflect consistent unqualified output
- Added comprehensive dump integration test covering functions, procedures, and string literal preservation
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| testdata/dump/issue_252_function_schema_qualifier/raw.sql | Test input with schema-qualified function/procedure bodies |
| testdata/dump/issue_252_function_schema_qualifier/pgschema.sql | Expected output showing stripped schema qualifiers (except in string literals) |
| testdata/dump/issue_252_function_schema_qualifier/pgdump.sql | Reference pg_dump output for comparison |
| testdata/dump/issue_252_function_schema_qualifier/manifest.json | Test case metadata and documentation |
| testdata/diff/dependency/table_to_function/diff.sql | Updated fixture showing public.documents → documents |
| testdata/diff/create_trigger/add_trigger_when_distinct/plan.json | Version bump to 1.7.0 |
| testdata/diff/create_trigger/add_trigger_system_catalog/plan.json | Version bump to 1.7.0 |
| testdata/diff/create_trigger/add_trigger_old_table/plan.json | Version bump to 1.7.0 |
| testdata/diff/create_trigger/add_trigger_constraint/plan.json | Version bump to 1.7.0 |
| testdata/diff/create_trigger/add_trigger/plan.txt | Removed function from diff (no longer differs after normalization) |
| testdata/diff/create_trigger/add_trigger/plan.sql | Removed function from diff (no longer differs after normalization) |
| testdata/diff/create_trigger/add_trigger/plan.json | Updated hash and removed function step (no longer differs) |
| ir/normalize.go | Core implementation: added stripSchemaPrefixFromBody and isIdentChar functions |
| cmd/dump/dump_integration_test.go | Added test case for issue #252 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
testdata/dump/issue_252_function_schema_qualifier/manifest.json
Outdated
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
public.users) while table definitions were dumped unqualified, causing inconsistency for downstream tools like sqlc that parse SQL staticallystripSchemaPrefixFromBodyinir/normalize.gothat strips the current schema qualifier from function/procedure bodies during normalization, while preserving string literals and cross-schema referencesissue_252_function_schema_qualifiercovering functions, procedures, and string literal preservationFixes #252
Test plan
TestDumpCommand_Issue252FunctionSchemaQualifierpasses — verifiespublic.usersis stripped from function/procedure bodies but'Table: public.users'(string literal) is preserveddependency/table_to_function,create_trigger/add_trigger) for consistent unqualified bodies./cmd/dump,./cmd/apply,./cmd/plan,./internal/diff,./ir)🤖 Generated with Claude Code