This is an SQL thing. Comparisons with NULL don’t return a boolean value but unknown. The return value of NULL != true is unknown, which is then treated as falsy. Thus the rows are filtered out. This is why SQL has IS NULL and friends, which you use with is_nil(q.field) in Ecto.