A model has two attributes of interest, forename and town. I want to search for Richard (London) and Brian (Madrid).
In long-hand,
p=Person.scoped
pred1=p.table[:forename].eq('Richard').and(p.table[:town].eq('London'))
pred2=p.table[:forename].eq('Brian').and(p.table[:town].eq('Madrid'))
pred3=pred1.or(pred2)
I would expect this to wrap the predicates in parentheses to maintain the integrity of the query. But looking at pred3.to_sql gives an unexpected response:
"(`person`.`forename` = 'Richard' AND `person`.`town` = 'London' OR `person`.`forename` = 'Brian' AND `person`.`town` = 'Madrid')"
How can I have Arel generate the correct query?