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:
Let’s take a look at the field definition:
Now let’s try in pure SQL:
Okay, finally we can see that
null that we’ve got in the first case is not a DB’s
It is just a valid JSON object like in:
CommentHas something on your mind? Tweet it!