drift
drift copied to clipboard
TypeAlias for $where functions and make default not private.
$where now generates a function with every table included in the query. It would be nice if this function had a type alias that could be imported.
I'm not sure I like this change to $where, its made my code more verbose without actually adding anything IMO but this would help a bit.
I've come around to it a bit more. I can see it can reduce errors
Thanks for the feedback! Yes, the intention was to improve safety (especially when a table is in scope multiple times under different aliases). You can still disable this feature by setting the scoped_dart_components build option to false, it's just the default which has changed.
I'm definitely open for ideas to make this more convenient, a type alias for the function could definitely be helpful.
Took quite a bit of work (mainly because riverpod doesn't let you pass more than 1 argument around) to convert some complex and dynamic filters (one with 11 tables joined) for this change but I was able to keep riverpod provider updates to the same amount.
A type alias could be useful for my use case as generally when i'm using $where i'm reusing the the query in multiple places to build dynamic queries. Having the params type aliased and the default value accessible would mean I don't need to redefine something drift is already generating.