You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if Drift implements the column option clientGeneratedAs. It would look like clientDefault, taking a function that accepts the companion as input, and returns a Value<ColumnType>?, but it would be executed every time we mutate the data in the database.
It would allow us to specify how data mutates in the database without the need of using companion.copyWith() to mutate the search, which in this case changes when name changes.
The text was updated successfully, but these errors were encountered:
I think I understand what you're getting at, but I'm still trying to understand how this use case is distinct from a stored generatedAs. Is the intention essentially to run more complex Dart code in generatedAs?
I guess what mainly worries me is how this would play out with e.g. a CustomersCompanion.custom used to insert or update rows based on arbitrary SQL expressions.
It's worth mentioning that this is possible already (at least in SQLite) by defining a custom function:
final db =Database(NativeDatabase.memory(setup: (database) {
database.createFunction(
functionName:'remove_diacritics',
function: (args) {
return (args[0] asString).removeDiacritics();
},
);
}));
And then calling something like this in generatedAt:
It would be nice if Drift implements the column option
clientGeneratedAs
. It would look likeclientDefault
, taking a function that accepts the companion as input, and returns aValue<ColumnType>?
, but it would be executed every time we mutate the data in the database.For example:
It would allow us to specify how data mutates in the database without the need of using
companion.copyWith()
to mutate thesearch
, which in this case changes whenname
changes.The text was updated successfully, but these errors were encountered: