drift icon indicating copy to clipboard operation
drift copied to clipboard

TypeAlias for $where functions and make default not private.

Open North101 opened this issue 3 years ago • 2 comments

$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.

North101 avatar Aug 15 '22 12:08 North101

I've come around to it a bit more. I can see it can reduce errors

North101 avatar Aug 15 '22 13:08 North101

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.

simolus3 avatar Aug 15 '22 14:08 simolus3

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.

North101 avatar Aug 18 '22 11:08 North101