-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
handling null values in comparision operator expressions #3688
Comments
@karthikvt26 We can achieve this using the follwing condition right?
|
@rikinsk Yes that is exactly what I am doing. But this could become problematic when it comes to coding it since we are adding it at the first level of where. |
@karthikvt26 Can you explain this in more detail. Whats the exact problem here because of that? |
For example:
rather than a query as below
Now if there is a scenario user is trying to filter by "" or null for columnB too, it becomes slightly cumbersome to convert the entire where clause into |
So the takeaway for me here is that devs dont want to think of null as a special value and find it easier if it were treated like any other value while using the API. @coco98 @0x777 Should we just do the handling of nulls internally in hasura and call it a day regarding all edge cases caused by null values. |
I think the reasoning is more from a point of view of |
We can try to do this but it'll be a little tricky, for example, if we want |
Regarding the overall handling of nulls, I just found my delete mutation deleted all of the data in a table. It turns out this was because I accidentally passed a null value to a parameter in my query. Instead of running the Is this one of the edge cases that @rikinsk mentions above? |
@RapidOwl This is an issue with the way nulls are handled in compare expressions. You can see #704 (comment) (and the thread before it for context) on the latest status of this issue |
Awesome thanks for pointing me in the right direction. For now, I’ll super sanitise my inputs. |
When dealing with conditions in Hasura 1.3.3, seems that passing null to _eq, _like, and other comparison operators effectively switched filtering off. This was very convenient for me when developing JS frontend, because I have a bunch of queries like that:
It worked when I passed null values to the variables and thus switched off corresponding conditions. But unexpectedly, this is broken in Hasura 2.0! For string operators, I can pass '%' easily, but for integer, there is no universally matching value. Wondering if handling of nulls is desired behavior and what coding approach is suggested for these cases? Constructing graphql queries programmatically by including conditions is cumbersome... |
Here is the screenshot of the operators and their types
I have a string column which is nullable. It can contain
empty string
~ "" ,null
and non-zero length string. I would like to run a query with_in: ["", null]
. But its not allowed based on the schema.The text was updated successfully, but these errors were encountered: