Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-1122

Parsing OR conditions in Where clause throws an exception

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Ubuntu Dedicated Server

      Description

      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.

        Activity

        Hide
        beberlei Benjamin Eberlei added a comment -

        Fixed formatting, scheduled for 2.0.5

        Show
        beberlei Benjamin Eberlei added a comment - Fixed formatting, scheduled for 2.0.5
        Hide
        beberlei Benjamin Eberlei added a comment -

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

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

        Show
        beberlei Benjamin Eberlei added a comment - It works for me outside the QueryBuilder context when using DQL itself. Can you call $qb->getQuery()->getDQL() and print that here?
        Hide
        guilhermeblanco Guilherme Blanco added a comment -

        As stated by this passing unit test:

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

        This issue is invalid for assigned fix version.

        Show
        guilhermeblanco Guilherme Blanco added a comment - As stated by this passing unit test: https://github.com/doctrine/doctrine2/commit/1e9e2de73740667de49847392d978eb4847217a2 This issue is invalid for assigned fix version.

          People

          • Assignee:
            guilhermeblanco Guilherme Blanco
            Reporter:
            deatheriam Oleg Namaka
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: