DDC-1260: Enable nesting of OR and AND statements in DQL queries #1586

Closed
opened 2026-01-22 13:19:03 +01:00 by admin · 4 comments
Owner

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

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user t3andi:

Currently it is not allowed to nest AND and OR conditions in themselves. However, this comes in handy if you try to do a dynamic query rewriting, where you want to add some more conditions without knowing the original query before.

The fix is trivial, just allow to add AND in AND. The same needs to be done for OR. Patch will follow in a second...

Originally created by @doctrinebot on GitHub (Jul 8, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user t3andi: Currently it is not allowed to nest AND and OR conditions in themselves. However, this comes in handy if you try to do a dynamic query rewriting, where you want to add some more conditions without knowing the original query before. The fix is trivial, just allow to add AND in AND. The same needs to be done for OR. Patch will follow in a second...
admin added the Improvement label 2026-01-22 13:19:03 +01:00
admin closed this issue 2026-01-22 13:19:04 +01:00
Author
Owner

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

@doctrinebot commented on GitHub (Jul 8, 2011): - is required for [DDC-1299: Allow for nested Andx and Orx in QueryBuilder](http://www.doctrine-project.org/jira/browse/DDC-1299) - is duplicated by [DDC-1255: Can't add instance of Andx to QueryBuilder through andWhere](http://www.doctrine-project.org/jira/browse/DDC-1255)
Author
Owner

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

Comment created by @guilhermeblanco:

This can lead to unpredictable situations inside QueryBuilder.
Maybe we can add a "merge" function to Expr\Composite, I'm not sure.

I need to actually test it on every driver to make sure if it doesn't break anything. It was not originally designed to hold same instances. If you pay attention:

((a AND b) AND c) 

Is the same as:

a AND b AND c

Can't you make a check internally and use addMultiple?
In the meantime, I can make tests to check if it doesn't break anything else.

@doctrinebot commented on GitHub (Jul 8, 2011): Comment created by @guilhermeblanco: This can lead to unpredictable situations inside QueryBuilder. Maybe we can add a "merge" function to Expr\Composite, I'm not sure. I need to actually test it on every driver to make sure if it doesn't break anything. It was not originally designed to hold same instances. If you pay attention: ``` ((a AND b) AND c) ``` Is the same as: ``` a AND b AND c ``` Can't you make a check internally and use addMultiple? In the meantime, I can make tests to check if it doesn't break anything else.
Author
Owner

@doctrinebot commented on GitHub (Aug 8, 2011):

Comment created by @guilhermeblanco:

In this commit: 816ce41f63
I applied the support to this improvement, since it does not mess with generated code.

@doctrinebot commented on GitHub (Aug 8, 2011): Comment created by @guilhermeblanco: In this commit: https://github.com/doctrine/doctrine2/commit/816ce41f638d28934c79a12ef27f954124b2639e I applied the support to this improvement, since it does not mess with generated code.
Author
Owner

@doctrinebot commented on GitHub (Aug 8, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Aug 8, 2011): 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#1586