Search code examples
rubysequel

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


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?


Solution

  • You can use exclude instead of where.

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