I have this hash:
fields = {
name: 'John',
subject: 'Hello'
}
And I send this hash by this:
Email.where(fields).where(another_condition: 4).all
It works, however, When I want to add OR I need to explicitly define them:
fields = [
{
name: 'John',
subject: 'Hello'
},
{
name: 'Mark',
subject: 'Hi'
}
]
What I am trying to do here is merge this array of hashes in single WHERE
with OR:
SELECT * FROM emails WHERE another_condition = 4 AND (PUT ORs HERE)
which should look like:
SELECT * FROM emails WHERE another_condition = 4 AND ((name = "John" and
subject = "Hello") OR (name = "Mark" and subject = "Hi"))
How can I do that with Sequel using array of hashes so array oıf hashes
becomes ORs (I will add more where (and) after)
--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/e8991685-ae2e-4047-8b15-9c60fa487ef5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.