Fix for #1686

Adding an OR in the query was short-circuiting the logic.  We need to
group things with parentheses.