-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
NEQ doesn't work on joins #1242
Comments
This isn't a bug. The issue you're running into here is that you're querying a column that contains NULL values. In databases, a NULL value is an unknown value, not necessarily an "empty" value. In your example, the Toronto record has a random_id of NULL. In other words, you're saying that Toronto has some random_id that you don't know the value of. When you use You expect to get Toronto, because the |
"In databases" should be made more specific to "In Postgres." There are many databases that allow direct comparison operators to null values with the above expected results. Postgres provides It's not ideal to require users to write an RPC or create a custom view in place of using a standard operator, both of which are obfuscated when reading someone else's code. I struggle to imagine a frequent use case of someone using NEQ to a non-null value and expecting to not receive rows with null values, no matter how postgres may have chosen to implement null under-the-hood. |
the NEQ is actually a PostgREST behavior (which is what Supabase uses) https://docs.postgrest.org/en/v12/references/api/tables_views.html it looks like PostgREST already supports an "isDistinct"... I suspect it should be easy enough for the supabase team to add that in 🤷. They have a separate postgrest-js repo where they have this code... I'm assuming they just need to add it here: https://github.com/supabase/postgrest-js/blob/master/src/PostgrestFilterBuilder.ts |
Bug report
Describe the bug
Unable to use database filters on inner joins for nullable foreign keys
e.g.
from("tableA").select(", tableB()").eq("tableB.column", value) --> works
from("tableA").select(", tableB()").neq("tableB.column", value) --> does not work, always empty
To Reproduce
Schema:
Test Code
Output
Expected behavior
use neq random, expect canada cities --> should return canadian cities
Screenshots
If applicable, add screenshots to help explain your problem.
System information
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: