DDC-1122: Parsing OR conditions in Where clause throws an exception #1402

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

Originally created by @doctrinebot on GitHub (Apr 22, 2011).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user deatheriam:

I have the next query:

        $qb =  $this->_em->createQueryBuilder();

          $qb ->select('Inventory')
            ->from('\Entity\Inventory', 'Inventory')
            ->leftJoin('Inventory.Variant', 'Variant')
            ->where('(Variant.isSellable = 0) OR (Variant IS NULL)')
           ->getQuery()->getResult();

that throws an exception:

 PHP Fatal error:  Call to undefined method Doctrine\ORM\Query\AST\ConditionalExpression::isSimpleConditionalExpression() .../Doctrine/ORM/Query/SqlWalker.php on line 1378.```

 The SqlWalker::walkConditionalPrimary function expects the $primary parameter passed to it to be an instance of Doctrine\ORM\Query\AST\ConditionalPrimary, but it is actually an instance of Doctrine\ORM\Query\AST\ConditionalExpression class that is passed in that case and of course it does not have a method called isSimpleConditionalExpression.

The workaround is to use extra parentheses around the conditions: ((Variant.isSellable = 0) OR (Variant IS NULL)) which does not seem to be very intuitive way.
Originally created by @doctrinebot on GitHub (Apr 22, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user deatheriam: I have the next query: ``` $qb = $this->_em->createQueryBuilder(); $qb ->select('Inventory') ->from('\Entity\Inventory', 'Inventory') ->leftJoin('Inventory.Variant', 'Variant') ->where('(Variant.isSellable = 0) OR (Variant IS NULL)') ->getQuery()->getResult(); ``` that throws an exception: `````` PHP Fatal error: Call to undefined method Doctrine\ORM\Query\AST\ConditionalExpression::isSimpleConditionalExpression() .../Doctrine/ORM/Query/SqlWalker.php on line 1378.``` The SqlWalker::walkConditionalPrimary function expects the $primary parameter passed to it to be an instance of Doctrine\ORM\Query\AST\ConditionalPrimary, but it is actually an instance of Doctrine\ORM\Query\AST\ConditionalExpression class that is passed in that case and of course it does not have a method called isSimpleConditionalExpression. The workaround is to use extra parentheses around the conditions: ((Variant.isSellable = 0) OR (Variant IS NULL)) which does not seem to be very intuitive way. ``````
admin added the Bug label 2026-01-22 13:13:17 +01:00
admin closed this issue 2026-01-22 13:13:18 +01:00
Author
Owner

@doctrinebot commented on GitHub (Apr 30, 2011):

Comment created by @beberlei:

Fixed formatting, scheduled for 2.0.5

@doctrinebot commented on GitHub (Apr 30, 2011): Comment created by @beberlei: Fixed formatting, scheduled for 2.0.5
Author
Owner

@doctrinebot commented on GitHub (Apr 30, 2011):

Comment created by @beberlei:

It works for me outside the QueryBuilder context when using DQL itself.

Can you call $qb->getQuery()->getDQL() and print that here?

@doctrinebot commented on GitHub (Apr 30, 2011): Comment created by @beberlei: It works for me outside the QueryBuilder context when using DQL itself. Can you call $qb->getQuery()->getDQL() and print that here?
Author
Owner

@doctrinebot commented on GitHub (May 13, 2011):

Comment created by @guilhermeblanco:

As stated by this passing unit test:

https://github.com/doctrine/doctrine2/commit/1e9e2de73740667de49847392d978eb4847217a2

This issue is invalid for assigned fix version.

@doctrinebot commented on GitHub (May 13, 2011): Comment created by @guilhermeblanco: As stated by this passing unit test: https://github.com/doctrine/doctrine2/commit/1e9e2de73740667de49847392d978eb4847217a2 This issue is invalid for assigned fix version.
Author
Owner

@doctrinebot commented on GitHub (May 13, 2011):

Issue was closed with resolution "Invalid"

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

No dependencies set.

Reference: doctrine/archived-orm#1402