Skip to content

Cannot query null colums in supabase. #664

@przste-go

Description

@przste-go

Hey! I've got a small problem when trying to query for null values using brick with Supabase.

Summary

When querying for NULL values using Where('field', value: null), Brick generates invalid PostgREST syntax (eq.null) instead of the correct is.null syntax required by PostgREST. This will cause it to check for string equality instead of null value of the column.

Proposed Fix

Could we possibly do something like (In packages/brick_supabase/lib/src/query_supabase_transformer.dart line ~193)

    String qk;
    // Magic condition to convert null values
    if (condition.value == null) {
      qk = condition.compare == Compare.notEqual ? 'not.is.null' : 'is.null';
    } else if (condition.compare == Compare.inIterable && condition.value is Iterable) {
      qk = 'in.(${(condition.value as Iterable).join(',')})';
    } else {
      qk = '${_compareToSearchParam(condition.compare)}.${condition.value}';
    }

    return [
      {
        queryKey: qk,
      },

Or maybe I have missed something and that's intended behaviour ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions