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

Not Equal filter returns data that matches the filter (neq) #575

Closed
Abdolla25 opened this issue Oct 1, 2023 · 3 comments
Closed

Not Equal filter returns data that matches the filter (neq) #575

Abdolla25 opened this issue Oct 1, 2023 · 3 comments
Labels
postgrest Issues related to postgrest-py question Further information is requested

Comments

@Abdolla25
Copy link

Describe the bug
I'm using supabase with django app, whenever I use neq filter over foriegn table it returns all data, only the data matches the filter returned with "None" on the filter key instead of being neglected at all

to be more clear:

data = (
    supabase.table("dashboard_payment")
    .select(
        "id, note, paymentType, amount, dashboard_client(id, name, classification), auth_user(first_name, last_name), created, updated"
    )
    .neq("dashboard_client.classification", "SYSTEM")
    .gte("created", date_range["start"])
    .lte("created", date_range["end"])
    .execute()
    .dict()["data"]
)

data returned from this:

[
   {
      "id":xxxx,
      "note":"xxxxx",
      "paymentType":"xxxxx",
      "amount":xxx,
      "created":"xxxxxx",
      "updated":"xxxxxx",
      "dashboard_client":"None",
      "auth_user":{
         "first_name":"xxxxxx",
         "last_name":"xxxxxxx"
      }
   },
   {
      "id":xxxxx,
      "note":"xxxxxx",
      "paymentType":"xxxxxxx",
      "amount":xxxxxxx,
      "created":"xxxxxxxxx",
      "updated":"xxxxxxxx",
      "dashboard_client":{
         "id":xx,
         "name":"xxxxxxx",
         "classification":"xxxxxxxx"
      },
      "auth_user":{
         "first_name":"xxxxxxx",
         "last_name":"xxxxxxxx"
      }
   }
]

as you can see, first record should be filtered not returned with value None on dashboard_client field

Am I using this client wrong?

@anand2312
Copy link
Contributor

I don't quite get you - does the first record not have a related record in dashboard_client, is that why it is None? If that is the case I think the response technically makes sense, because None != "SYSTEM"

@anand2312 anand2312 added question Further information is requested postgrest Issues related to postgrest-py labels Oct 2, 2023
@Sahithiaele
Copy link

It seems like you are encountering an issue with the Supabase query filter not working as expected, specifically with the neq (not equal) filter on a foreign table. The problem might be related to how Supabase handles the filtering on nested fields.

One potential solution is to use the is or is_not filter for explicit comparison with None on the dashboard_client.classification field.

data = ( supabase.table("dashboard_payment") .select( "id, note, paymentType, amount, dashboard_client(id, name, classification), auth_user(first_name, last_name), created, updated" ) .is_not("dashboard_client.classification", None) .gte("created", date_range["start"]) .lte("created", date_range["end"]) .execute() .dict()["data"] )

@silentworks
Copy link
Contributor

No reply from OP for over 5 months now. Closing this one out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
postgrest Issues related to postgrest-py question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants