Recommended way to do IS DISTINCT FROM
, not_eq_or_null
or not_cont_or_null
#1560
Unanswered
jaykilleen
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am going down the rabbit hole of understanding why a simple query like
name not_cont '%abc%'
was not returning results where name was NULL.At first I thought I wasn't using ransack correctly but after runnning
.to_sql
and using those results in pgadmin I realised it was postgres and then further realising the sql standard treats nulls as unknown values and hence you can't knowingly use them in a!=
orNOT ILIKE
query.So, what is the recommended way then, for us to do
not_eq_or_null
in Ransack??I am going down the path patching areal and using ransack custom predicates.
Sounds like using
IS DISTINCT FROM
would also be good but doesn't appear to be supported in Arel due to incompatibilities with other databases (ie not Postgresql).Does this sound like the way? If anyone has any advice that would be appreciated. I'll try and write up my method here when I get something that works well.
https://groups.google.com/g/rubyonrails-core/c/VSR1I1iwxJo?pli=1
https://medium.com/@justinboylantoomey/postgres-not-equal-only-returns-non-null-values-5f0a42fa75dc
https://wiki.postgresql.org/wiki/Is_distinct_from
Beta Was this translation helpful? Give feedback.
All reactions