SchemaPlus / schema_validations

Automatically creates validations basing on the database schema.
Other
174 stars 34 forks source link

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

Open rapind opened 7 years ago

rapind commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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