I'm trying to query the equivalent of this sql snippet using arel:
WHERE (("participants"."accepted" = 'f' AND "participants"."contact_id" = 1)
OR "participants"."id" IS NULL)
So I want (accepted && contact_id=1) OR NULL
Here's what I've got in AREL
participants[:accepted].eq(false).and(participants[:contact_id].eq(1).
or(participants[:id].is(nil)
Problem is, this generates:
("participants"."accepted" = 'f' AND "participants"."contact_id" = 1 OR "participants"."id" IS NULL)
Note the lack of parentheses around my and conditions. I believe that according to the operator precedence, that I'm getting:
accepted && (contact_id=1 OR NULL)
Adding parentheses in in the AREL query has no affect. Any thoughts?