Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There doesn't seem to be a way to check the difference between null and 'null' in the is() filter #557

Open
AdamGEmerson opened this issue Sep 22, 2023 · 1 comment

Comments

@AdamGEmerson
Copy link

Describe the bug

It seems that when using .is(), there is no way to query for string literals that say "null".

In the supabase js library, this is the given example for is():

DB

create table
  countries (id int8 primary key, name text);

insert into
  countries (id, name)
values
  (1, 'null'),
  (2, null);

Query

const { data, error } = await supabase
  .from('countries')
  .select()
  .is('name', null)

Response

{
  "data": [
    {
      "id": 1,
      "name": "null"
    }
  ],
  "status": 200,
  "statusText": "OK"
}

This behavior cannot be replicated in the python library because rather than substituting None for the js keyword null, the python library uses the string 'null' to check for nullness in the database.

Replicating this in the python library gives a different result, row 2.

data, count = supabase.table('countries') \
  .select('*') \
  .is_('name', 'null') \
  .execute()
('data', [{'id': 2, 'name': None}])

@AdamGEmerson
Copy link
Author

On second look, this might just be an issue with the JS documentation. I suppose the correct way to query for a string "null" would be using .eq() not .is_(). I'll try messing around with JS library to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant