DDC-2113: SQLFilter incorrect results when WHERE clause contains OR expression #2662

Closed
opened 2026-01-22 13:59:34 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 1, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user vclayton:

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.

Originally created by @doctrinebot on GitHub (Nov 1, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user vclayton: 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.
admin added the Bug label 2026-01-22 13:59:34 +01:00
admin closed this issue 2026-01-22 13:59:35 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 5, 2012):

Comment created by @FabioBatSilva:

Fixed : 129d6efd85

@doctrinebot commented on GitHub (Nov 5, 2012): Comment created by @FabioBatSilva: Fixed : https://github.com/doctrine/doctrine2/commit/129d6efd8585458fd4bde2a3eb9a5cac374f54fe
Author
Owner

@doctrinebot commented on GitHub (Nov 5, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Nov 5, 2012): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2662