Discussion about changing default nullability in Ash 4

Hi, I’ve opened a discussion on Github whenever it makes sense to change the default for nullability in Ash 4.

Right now allow_nil? option for all fields has true as a default. And to me, based on what I’ve seen in codebases, it feels like a wrong one - it’s just a less strict option that needs opt-out more often than not and because of that introduces noise to code and decreases its readability. Also it is unintuitive (so often needs to be explained to first-time users) because it does not match Elixir or even Ash conventions.

Interested in your opinions:

a) Do you find nullability by default annoying or logical and convenient?

b) If you do prefer things to be other way around and it was up to you whenever such a breaking change is introduced in Ash 4 - would you still be in favor of making the change or choose to keep things as is (because, let’s say, it is not that important and to minimize changes)?

3 Likes

a.) rather not have nullability by default
b.) option flag in 3 defaulting to nillability, switching the default value in 4.

Igniter is probably not an option as we don’t know what user code relies on the current behaviour. (?)

1 Like

The igniter script would go through and set the value of allow_nil?: true to all attributes that don’t have the option set to false, so resources would maintain their current behavior.

1 Like

But it does match standard RDBMS/SQL conventions (NOT NULL) which many may be familiar with.

For the record I am not an Ash user but I do get annoyed typing null: false in all of my Ecto migrations so I’d probably give this a thumbs-up! :slight_smile: