supabase / postgrest-dart

Dart client for PostgREST
https://supabase.com
MIT License
136 stars 38 forks source link

filter() and not() cannot take a list of values for operator 'in' #32

Closed jofmi closed 2 years ago

jofmi commented 3 years ago

Problem description

In /lib/src/postgrest_filter_builder.dart, the method in() seems to use the method _cleanFilterArray() to reformat lists so that lists of values can be passed:

  PostgrestFilterBuilder in_(String column, List values) {
    appendSearchParams(column, 'in.(${_cleanFilterArray(values)})');
    return this;
  }

The method filter() and not() do not do this, so lists cannot be passed:

  PostgrestFilterBuilder not(String column, String operator, dynamic value) {
    appendSearchParams(column, 'not.$operator.$value');
    return this;
  }

This makes it difficult to run the command NOT IN.

Possible solutions

  1. Don't allow the operator 'in' for filter() and not() and make a new method for NOT IN
  2. Use _cleanFilterArray() in filter() and not() if the passed value for value is a list
phamhieu commented 3 years ago

For now, you can do like this. Let me know if this solves your problem

jofmi commented 3 years ago

Thanks @phamhieu! For now, I have solved it by applying _cleanFilterArray() to my lists before I pass them to not()