drift icon indicating copy to clipboard operation
drift copied to clipboard

Nullable Columns Without Defaults use `Value`

Open dickermoshe opened this issue 1 year ago • 3 comments

Nullable Columns Without Defaults

Why does this column need to be constructed with a Value e.g. create(title:Value("Pizza"))

TextColumn get title => text().nullable()();

It can be empty because a withDefault or clientDefault wasn't provided. So Value.empty() has the exact same effect as null.

dickermoshe avatar Sep 10 '24 13:09 dickermoshe

Good point! Changing this would be breaking, but IMO it would make things easier if create / Companion.insert only requires a value wrapper if the column is nullable and has a default.

simolus3 avatar Sep 10 '24 19:09 simolus3

How queezy are you about breaking releases? Would you make one just for this?

dickermoshe avatar Sep 11 '24 04:09 dickermoshe

Not just for this, but having one for all breaking enhancement could be worth it.

The reason I'm holding back on breaking releases is that with macros coming up eventually, we'll probably have some major design changes on how tables are defined - I don't want to do to two breaking releases in short succession (from experience, it takes actual years until we stop getting issues for outdated major versions).

Since this only affects the generator, I think we can introduce a builder option as an opt-in. In a future major release, we make this the default (e.g. an opt-out) or the only generation mode.

simolus3 avatar Sep 11 '24 20:09 simolus3