On Friday, July 7, 2017 at 10:45:11 AM UTC-7, Tom Willis wrote:
>
> Trying to understand this and wondering whether it's a bug or not.
>
>
>
> DB[:table].where(Sequel.|({is_active: false}, {is_complete: true})).sql
> => "SELECT * FROM \"table\" WHERE ((\"is_active\" IS FALSE) OR
> (\"is_complete\" IS TRUE))"
> [19] pry(main)> DB[:table].exclude(Sequel.|({is_active: false},
> {is_complete: true})).sql
> => "SELECT * FROM \"table\" WHERE ((\"is_active\" IS NOT FALSE) AND
> (\"is_complete\" IS NOT TRUE))"
> [20] pry(main)>
>
>
>
> when you change the where to exclude the "OR" becomes an "AND". is this a
> bug? If so, is there a way around it?
>
That's not a bug, that's that's expected behavior following the rules of
boolean logic:
NOT (A OR B) = NOT A AND NOT B
If you want:
NOT A OR NOT B
then that is the same as:
NOT (A AND B)
so you can use:
exclude(Sequel.&({is_active: false}, {is_complete: true}))
or just:
exclude(is_active: false, is_complete: true)
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.