On Monday, August 6, 2012 5:47:42 PM UTC-7, Matt Hauck wrote:
>
> I'm having a hard time figuring out how to do an "OR" in any useful way.
> It is not clear to me how to structure it so that AND and ORs are
> structured logically how I want them to be.
>
> I have just figured out that testing "col != value" does not work of the
> column is NULL. So, I need to do something like:
>
> ds.where(:key_col => key).exclude(:col => value).or(:col => nil)
>
> This doesn't work, but I was hoping it would generate something like:
>
> SELECT * FROM table WHERE key_col = 'key' AND (col != 'value' OR col IS
> NULL)
>
> Anyway I can do this with Sequel?
>
With the core extensions:
ds.where(:key_col => key).where(~{:col => value} | {:col => nil})
Without the core extensions:
ds.where(:key_col => key).where(Sequel.~(:col => value) | {:col => nil})
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/deOyWQqlUR0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.