[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


 Description   

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

Example:

  • 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"

Expected:
"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.



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

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

Generated at Mon Nov 24 02:42:51 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.