Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 4 comments

2 participants

@doctrinebot

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.
@doctrinebot

Comment created by @beberlei:

Fixed formatting, scheduled for 2.0.5

@doctrinebot

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

Comment created by @guilhermeblanco:

As stated by this passing unit test:

1e9e2de

This issue is invalid for assigned fix version.

@doctrinebot

Issue was closed with resolution "Invalid"

@doctrinebot doctrinebot added this to the 2.1 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.