simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.67k stars 372 forks source link

Nullable Columns Without Defaults use `Value` #3213

Open dickermoshe opened 2 months ago

dickermoshe commented 2 months ago

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.

simolus3 commented 2 months ago

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.

dickermoshe commented 2 months ago

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

simolus3 commented 2 months ago

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.