Skip to content
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

Presence validation still happening for array field w/ null: false and default: [] #55

Open
rapind opened this issue May 31, 2017 · 2 comments

Comments

@rapind
Copy link

rapind commented May 31, 2017

Given the following migration:

t.text :my_field, array: true, null: false, default: []

There's still a presence validation being added when there shouldn't be.

This is w/ Version 2.2.1

@urkle
Copy link
Member

urkle commented Sep 20, 2017

precence validations should NOT be added for columns that have a default like this. this applies to array fields as well as json or jsonb fields (that have a default). As we are simply stating (for the DB) that we want it to never be null, but have a an empty representation by default.. {} or [].

We encounter this with
t.jsonb :my_field, null: false, default: {}

@urkle
Copy link
Member

urkle commented Sep 20, 2017

so for now.. it's schema_validations except: :my_field

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

No branches or pull requests

2 participants