How do I test for non-null in Ruby::Sequel?

Eric picture Eric · May 26, 2014 · Viewed 7k times · Source

I'm looking to do something like

User.select(...).where(:name != nil)

without writing something like

User.select(...).to_a.find_all {|user| user.name}

I can select for null values, but not for non-null. Is there a trick, or outside Sequel's domain?

Answer

Alex Peachey picture Alex Peachey · May 27, 2014

You can use exclude instead of where.

User.select(...).exclude(name: nil)