PostgreSQL’s IS DISTINCT FROM.
02 Jul 2018Sometimes you need to find records which field is not equal to given value or is NULL
. And instead of writing something like:
User.where('email != ? OR email IS NULL', 'test@example.com')
you can use pretty handy PostgreSQL’s IS DISTINCT FROM
comparison operator:
User.where('email IS DISTINCT FROM ?', 'test@example.com')