I'd like to find rows in my table that have end_date NULL or not present.

I am not sure how to do this with PostgreSQL nor could I find any useful examples online. I am using Rails though.

I tried sth like:

   Tag.where("end_date IS ?", nil)

and also

 Tag.where("end_date IS NULL")

Without success. The above returns all the tags that exist which is wrong. Maybe I should do it sth like

 Tag.where("end_date IS NOT DATE")

I'd appreciate any answers!

有帮助吗?

解决方案

Use a hash in where():

Tag.where({ end_date: nil })
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top