fix: resolve integer/enum types with limit in add_column#235
Open
cbisnett wants to merge 2 commits intoPNixx:masterfrom
Open
fix: resolve integer/enum types with limit in add_column#235cbisnett wants to merge 2 commits intoPNixx:masterfrom
cbisnett wants to merge 2 commits intoPNixx:masterfrom
Conversation
add_column ignored :limit and :unsigned options for :integer and :enum types because type resolution only happened in TableDefinition (used by create_table). This caused add_column to always produce the default type (e.g. UInt32 for integers) regardless of the limit specified. Extract the type resolution logic into resolve_type_with_limit and call it from add_column before delegating to super. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- TableDefinition#integer now delegates to the adapter's resolve_integer_kind, eliminating duplicated logic - Fix signed limit: 5 falling through to UInt32 instead of Int64 (condition was > 5, now >= 5) - Add test coverage for limit: 5 signed integer case Co-Authored-By: Claude Opus 4.6 <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.
Summary
add_columnwith:integeror:enumtypes ignored:limitand:unsignedoptions, always producing the default type (e.g.UInt32for integers instead ofInt16whenlimit: 2, unsigned: false)TableDefinition(used bycreate_table), butadd_columnbypassed it and went through Rails'type_to_sqlwhich only looks upNATIVE_DATABASE_TYPESresolve_type_with_limit(private method on the adapter) and calls it fromadd_columnbefore delegating tosuperExample
Test plan
add_columnusing variouslimit/unsignedcombos for integer typesInt16,Int32,Int64,UInt8,UInt16,UInt64,UInt32🤖 Generated with Claude Code