[DDC-2113] SQLFilter incorrect results when WHERE clause contains OR expression Created: 01/Nov/12  Updated: 09/Nov/12  Resolved: 05/Nov/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2.2, 2.3, Git Master
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Major
Reporter: Vaughn Clayton Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


When using an SQLFilter, if applied to a query that contains only OR expressions in the WHERE clause, the generated SQL is incorrect.


  • SQLFilter returns a constraint like "{$tableAlias}.accountid={$accountId}"
  • Query: "SELECT u FROM User u WHERE u.fname='bob' OR u.lname='bob'"

Resulting SQL:
"SELECT u FROM User u WHERE u.fname='bob' OR u.lname='bob' AND u.accountid=2"

"SELECT u FROM User u WHERE (u.fname='bob' OR u.lname='bob') AND u.accountid=2"

The problem is that the order of operations is wrong. I'm getting users who aren't in account 2, making SQLFilter unreliable.

Comment by Fabio B. Silva [ 05/Nov/12 ]

Fixed : https://github.com/doctrine/doctrine2/commit/129d6efd8585458fd4bde2a3eb9a5cac374f54fe

Generated at Tue Dec 01 00:41:57 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.