Where is not null

Hi, I’m quite new to Hanami and to Ruby in general so please forgive me if this is a stupid question:

How do I express the SQL WHERE column_name IS NOT NULL in Rom? I’ve tried where(column_name: !nil) and where { column_name != nil } and neither works.

I can also see in the debug output that using the block condition with any random condition (like where { banana == face } results in the SQL WHERE (1 = 0) rather than an error, which is what I would expect.

EDIT: Also, I hope this is the right forum to ask this in.

You could try where { column_name.not(nil) }

Negative Restrictions

exclude(column_name: nil)
exclude { column_name.is(nil) }

where { column_name != nil } becomes where { false } which becomes WHERE 1 = 0

Negative Restrictions

Clearly I haven’t been reading the documentation well enough to miss this. Thank you both :blush:

I love that you’re here, trying Hanami, and asking questions, @ririya! This is itself a great contribution to our community, please be our guest to keep on asking things! :heart: