Here’s the story of how ActiveRecord’s where.not(field: nil)
may still happen to return nil
in Postgres.
This funny thing happened to me today when I was checking Honeybadger errors having my cup of morning coffee.
The essence of the error looked like this:
NoMethodError: undefined method 'dig' for nil:NilClass
Hmmm. I moved my coffee away and decided to dive into details:
O_o
Let’s take a look at the field definition:
Now let’s try in pure SQL:
But wait…
Okay, finally we can see that null
that we’ve got in the first case is not a DB’s NULL
, actually.
It is just a valid JSON object like in:
Comment
Has something on your mind? Tweet it!