-
Notifications
You must be signed in to change notification settings - Fork 29
Fix array type handling in IsTextLikeType for USING clause generation #211
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
Merged
Conversation
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
Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update USING clause for text-to-enum conversions
Fix array type handling in IsTextLikeType for USING clause generation
Dec 18, 2025
Contributor
|
@copilot you should not create new text cases. Instead you should add the text[] to the existing testdata/diff/create_table/alter_column_types |
…es test Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com>
Contributor
Author
tianzhou
added a commit
that referenced
this pull request
Dec 18, 2025
* fix: add USING clause for text-to-enum type conversions (#190) When converting columns from text-like types (text, varchar, char) to custom types like ENUMs, PostgreSQL requires an explicit USING clause. Additionally, columns with default values need special handling during type changes: drop default, alter type, then re-add default. Changes: - Add USING clause when converting from text-like to non-built-in types - Handle default values during type change (drop -> alter -> set) - Add IsBuiltInType and IsTextLikeType helpers to ir/normalize.go - Add test cases for text-to-enum conversion with and without defaults 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update internal/diff/column.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Optimize default value handling during type changes (#210) * Initial plan * Optimize default value handling for type changes without USING clause Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> * Fix array type handling in IsTextLikeType for USING clause generation (#211) * Initial plan * fix: handle array types in IsTextLikeType function Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> * refactor: consolidate array type tests into existing alter_column_types test Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> * chore: add missing updated plan --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
alecthomas
pushed a commit
to alecthomas/pgschema
that referenced
this pull request
Jan 26, 2026
* fix: add USING clause for text-to-enum type conversions (pgplex#190) When converting columns from text-like types (text, varchar, char) to custom types like ENUMs, PostgreSQL requires an explicit USING clause. Additionally, columns with default values need special handling during type changes: drop default, alter type, then re-add default. Changes: - Add USING clause when converting from text-like to non-built-in types - Handle default values during type change (drop -> alter -> set) - Add IsBuiltInType and IsTextLikeType helpers to ir/normalize.go - Add test cases for text-to-enum conversion with and without defaults 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update internal/diff/column.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Optimize default value handling during type changes (pgplex#210) * Initial plan * Optimize default value handling for type changes without USING clause Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> * Fix array type handling in IsTextLikeType for USING clause generation (pgplex#211) * Initial plan * fix: handle array types in IsTextLikeType function Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> * refactor: consolidate array type tests into existing alter_column_types test Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tianzhou <230323+tianzhou@users.noreply.github.com> * chore: add missing updated plan --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.
The
IsTextLikeTypefunction didn't strip array suffixes before checking base types, causing incorrect USING clause logic for array type conversions (e.g.,text[]→custom_enum[]).Changes
strings.TrimSuffix(t, "[]")toIsTextLikeType, matching the pattern inIsBuiltInTypetext[]→enum[]conversion test case to existing testExample
The fix ensures array types like
text[],varchar[], andchar[]are recognized as text-like, triggering USING clause generation for conversions involving custom types.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.