-
Notifications
You must be signed in to change notification settings - Fork 29
fix: include public in search_path for extension type resolution #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 fixes issue #197 where extension types installed in the public schema (e.g., citext) failed to resolve when applying SQL to temporary schemas because the search_path only included the temp schema.
Key changes:
- Modified search_path in all schema application code to include both the target schema and public as a fallback
- Added
ParseSQLToIRWithSetup()function to execute setup SQL after schema recreation but before main SQL - Updated test infrastructure to make setup.sql files idempotent and demonstrate the fix with citext extension
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| testutil/postgres.go | Added ParseSQLToIRWithSetup() helper and updated search_path to include public schema for extension type resolution |
| internal/postgres/external.go | Updated search_path in production code to include public schema as fallback for extension types |
| internal/postgres/embedded.go | Updated search_path in embedded postgres to include public schema as fallback for extension types |
| internal/diff/diff_test.go | Refactored to use ParseSQLToIRWithSetup() instead of executing setup.sql before schema recreation |
| testdata/diff/create_table/add_column_cross_schema_custom_type/setup.sql | Made setup idempotent with DROP/CREATE and moved citext to public schema to reproduce issue #197 |
| testdata/diff/create_table/add_column_cross_schema_custom_type/new.sql | Updated test to use unqualified citext type in public schema demonstrating natural usage pattern |
| testdata/diff/create_table/add_column_cross_schema_custom_type/plan.txt | Updated expected output to reflect citext being unqualified in public schema |
| testdata/diff/create_table/add_column_cross_schema_custom_type/plan.sql | Updated expected migration SQL with correct type qualification |
| testdata/diff/create_table/add_column_cross_schema_custom_type/diff.sql | Updated expected diff output with correct type qualification |
| testdata/diff/create_function/alter_function_same_signature/setup.sql | Made setup idempotent with DROP/CREATE for consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bf8ab92 to
8cb94c3
Compare
When applying SQL to temporary schemas, extension types installed in the public schema (e.g., citext) failed to resolve because the search_path only included the temp schema. Changes: - Add public to search_path in embedded.go, external.go, and testutil - Add ParseSQLToIRWithSetup() for tests needing setup SQL after schema reset - Fix type comparison to normalize schema prefix before comparing - Fix ADD COLUMN and ALTER COLUMN TYPE to properly unqualify types - Update test case to reproduce the bug with citext in public schema - Make setup.sql files idempotent for repeated execution 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
8cb94c3 to
9e4eec2
Compare
There was a problem hiding this 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 14 out of 14 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.
…lex#197) (pgplex#208) When applying SQL to temporary schemas, extension types installed in the public schema (e.g., citext) failed to resolve because the search_path only included the temp schema. Changes: - Add public to search_path in embedded.go, external.go, and testutil - Add ParseSQLToIRWithSetup() for tests needing setup SQL after schema reset - Fix type comparison to normalize schema prefix before comparing - Fix ADD COLUMN and ALTER COLUMN TYPE to properly unqualify types - Update test case to reproduce the bug with citext in public schema - Make setup.sql files idempotent for repeated execution 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Fix #197
When applying SQL to temporary schemas, extension types installed in the public schema (e.g., citext) failed to resolve because the search_path only included the temp schema.
Changes:
stripSchemaPrefixin generating type statement🤖 Generated with Claude Code