DDC-1242: WHERE clause with OR is not surrounded by parentheses #1565

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

Originally created by @doctrinebot on GitHub (Jul 1, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user hype:

Found a BC break in 2.1.0RC2.

echo $qb->select('e')->from('SomeEntity', 'e')->where('1 = 1')->andWhere('2 = 2 OR 3 = 3')->getDQL();

The above query with an OR inside a where clause creates the following DQL in 2.0.6:

SELECT e FROM SomeEntity e WHERE (1 = 1) AND (2 = 2 OR 3 = 3)

But in 2.1.0RC2 it creates this DQL:
SELECT e FROM SomeEntity e WHERE 1 = 1 AND 2 = 2 OR 3 = 3

Which is obviously not what I want. Manually putting parentheses inside the andWhere or using $qb->expr()->or(...) inside the andWhere fixes this.

Originally created by @doctrinebot on GitHub (Jul 1, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user hype: Found a BC break in 2.1.0RC2. echo $qb->select('e')->from('SomeEntity', 'e')->where('1 = 1')->andWhere('2 = 2 OR 3 = 3')->getDQL(); The above query with an OR inside a where clause creates the following DQL in 2.0.6: SELECT e FROM SomeEntity e WHERE (1 = 1) AND (2 = 2 OR 3 = 3) But in 2.1.0RC2 it creates this DQL: SELECT e FROM SomeEntity e WHERE 1 = 1 AND 2 = 2 OR 3 = 3 Which is obviously not what I want. Manually putting parentheses inside the andWhere or using $qb->expr()->or(...) inside the andWhere fixes this.
admin added the Bug label 2026-01-22 13:18:15 +01:00
admin closed this issue 2026-01-22 13:18:16 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jul 3, 2011):

Comment created by @beberlei:

Duplicate of DDC-1237

@doctrinebot commented on GitHub (Jul 3, 2011): Comment created by @beberlei: Duplicate of [DDC-1237](http://www.doctrine-project.org/jira/browse/DDC-1237)
Author
Owner

@doctrinebot commented on GitHub (Jul 3, 2011):

Issue was closed with resolution "Duplicate"

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

No dependencies set.

Reference: doctrine/archived-orm#1565