Skip to content

Nullable arrays as parameters in drift file queries #3525

Answered by simolus3
frankvollebregt asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the report. The model drift_dev uses internally can't represent the concepts of nullable arrays (only arrays with nullable elements), so this is indeed impossible.

but hopefully illustrates the point

I'm actually not sure I understand the point to be honest. What would you expect brand in :brand to evaluate to if :brand is null, also NULL? Since those checks are most commonly used in WHERE clauses, isn't that effectively equivalent to just passing an empty list?

FWIW, one thing that should work today is:

getCarsMulti: SELECT * FROM cars WHERE :brands IS NOT NULL AND $brands;

Then you can call this in Dart:

getCarsMulti(
  brands: (car) => switch (brands) {
    null => const L…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@frankvollebregt
Comment options

Answer selected by frankvollebregt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants