fix: include public in search_path for extension type resolution#208
Merged
fix: include public in search_path for extension type resolution#208
Conversation
Contributor
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
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.
alecthomas
pushed a commit
to alecthomas/pgschema
that referenced
this pull request
Jan 26, 2026
…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>
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.
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