Skip to content

incorrect_length_validation: improve error message for array columns#236

Merged
gregnavis merged 1 commit into
gregnavis:masterfrom
fatkodima:incorrect_length_validation-array-columns
Jan 12, 2026
Merged

incorrect_length_validation: improve error message for array columns#236
gregnavis merged 1 commit into
gregnavis:masterfrom
fatkodima:incorrect_length_validation-array-columns

Conversation

@fatkodima

Copy link
Copy Markdown
Contributor

Postgres supports array columns and when they are defined with a limit (add_column :posts, :tags, :string, limit: 64, array: true), that limit applies to each element of the array (not to the array's length).

The gem's suggestion message is currently incorrect (the schema limits posts.tags to 64 characters but there's no length validator on Post.tags - remove the database limit or add the validator) as it suggests adding a length validator to the column, which will validate the array's length. This PR fixes that.

@gregnavis gregnavis left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Great improvement! Thank you for your contribution.

@gregnavis gregnavis merged commit f3bdcec into gregnavis:master Jan 12, 2026
40 checks passed
@fatkodima fatkodima deleted the incorrect_length_validation-array-columns branch January 12, 2026 13:20
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.

2 participants