-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
isdistinct doesn't work for null #2879
Comments
Treating the I'm not so sure about treating only the quoted We would need to get to an agreement on the syntax or if it should be implemented, because using |
A boolean looks more fit for
|
I'm fine either way, as long as the documentation is updated. Note that quotes already dropped inside an (btw: is there a good place to find all these rules and maybe some test-cases, so that library writers can make sure they get all these cases correct?) |
That's interesting, then maybe we aren't being completely consistent in parsing operators, or maybe there's something special that I'm missing for logical operators.
For now, this is documented in the Horizontal Filtering and the Working With PG Types sections in the docs. The tests we use for Filters could also be useful: postgrest/test/spec/Feature/Query/QuerySpec.hs Lines 31 to 335 in 40c2bcd
|
Thanks. When quoted, then I need to escape any I also need to quote column names that are equal to "or" or "and", and I do quote some other column names as well. However, I'm not completely sure what the rules for column names are. I wasn't able to access a column named Here is my encoding function: https://github.com/toitware/toit-supabase/blob/06f434e8e35705063965320639c0d8299a95c995/src/filter.toit#L305 Here are my test-cases for some string values: |
Finally got to understand this issue. So the problem is that: col=isdistinct.null Translates to: col IS DISTINCT FROM 'null' And it's expected to translate to col IS DISTINCT FROM NULL Which is reasonable. Though as Laurence mentions, it's possible to get the same behavior with
Seems possible to get that behavior by doing: col is distinct from nullif('null', 'null')::col_type; But not sure if we should do it or we should just document the limitation. |
I don't think we should change anything (except maybe for better documentation). The rules are simple. If you want to compare the column
|
Before we could do anything like that, we would need to clean up the whole quoting mess, as you already wrote in the other comments. See also: #1943 |
Environment
PostgreSQL version: (if using docker, specify the image)
public.ecr.aws/supabase/postgres:15.1.0.90
PostgREST version: (if using docker, specify the image)
public.ecr.aws/supabase/postgrest:v11.1.0
Operating system:
Linux
Description of issue
isdistinct
doesn't work fornull
values. It is not possible to get all rows that do not havenull
in it.Repro:
As can be seen in the example: the value that is passed to
isdistinct
must be the type of the column, and if the column is of type string, then theisdistinct
treats it like the string'null'
and not thenull
value.Expected behavior:
isdistinct
behaves similar toIS DISTINCT FROM
(as the documentation states) and thus:isdistinct.null
compares to thenull
value.isdistinct."null"
looks for the'null'
string.The text was updated successfully, but these errors were encountered: