Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2539

ResultVariable cannot be used in Like expressions

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.3.4
    • Fix Version/s: 2.4
    • Component/s: ORM
    • Security Level: All

      Description

      It is not possible to use ResultVariable in a like expression. For exemple :

      $qb ->select('c', 'SQRT(c.id) AS test')
      ->from('SomeClass', 'c')
      ->having('test LIKE \'%4%\'');

      return [Syntax Error] line 0, col 91: Error: Expected Literal, got 'LIKE'

      $qb ->select('c')
      ->from('SomeClass', 'c')
      ->having('c.id LIKE \'%4%\'');

      works, and :

      $qb ->select('c', 'SQRT(c.id) AS test')
      ->from('SomeClass', 'c')
      ->having('test = 4');

      works

      Changing Doctrine\ORM\Query\Parser LikeExpression function fix the problem (but has maby other consequences) :

      by replacing : "$stringExpr = $this->StringExpression();"
      by :
      $peek = $this->_lexer->glimpse();
      if($peek['value'] == 'LIKE')

      { // Simple Expression $stringExpr = $this->ArithmeticExpression(); }

      else

      { $stringExpr = $this->StringExpression(); }

        Activity

        Hide
        Serge Liszewski added a comment -

        After working on this issue, i really think it's a bug. I just add more details on the description

        Show
        Serge Liszewski added a comment - After working on this issue, i really think it's a bug. I just add more details on the description
        Hide
        Marco Pivetta added a comment -

        Duplicate of DDC-2615 (solved in master)

        Show
        Marco Pivetta added a comment - Duplicate of DDC-2615 (solved in master)

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Serge Liszewski
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: