Skip to content

fix: strip current schema qualifier from function/procedure bodies in dump (#252)#294

Merged
tianzhou merged 2 commits intomainfrom
fix/issue-252-strip-schema-qualifier-from-function-body
Feb 16, 2026
Merged

fix: strip current schema qualifier from function/procedure bodies in dump (#252)#294
tianzhou merged 2 commits intomainfrom
fix/issue-252-strip-schema-qualifier-from-function-body

Conversation

@tianzhou
Copy link
Contributor

Summary

  • 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
  • Added stripSchemaPrefixFromBody in ir/normalize.go that strips the current schema qualifier from function/procedure bodies during normalization, while preserving string literals and cross-schema references
  • Added dump integration test issue_252_function_schema_qualifier covering functions, procedures, and string literal preservation

Fixes #252

Test plan

  • New dump test TestDumpCommand_Issue252FunctionSchemaQualifier passes — verifies public.users is stripped from function/procedure bodies but 'Table: public.users' (string literal) is preserved
  • Updated existing test fixtures (dependency/table_to_function, create_trigger/add_trigger) for consistent unqualified bodies
  • Full test suite passes (./cmd/dump, ./cmd/apply, ./cmd/plan, ./internal/diff, ./ir)

🤖 Generated with Claude Code

… 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>
Copilot AI review requested due to automatic review settings February 16, 2026 17:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 stripSchemaPrefixFromBody function 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.documentsdocuments
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.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tianzhou tianzhou merged commit 0daf757 into main Feb 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Force qualified names in dump

1 participant