Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-612

Query\Expr::substring() third parameter should be optional

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA1
    • Fix Version/s: 2.0-BETA2
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None

      Description

      I'm not aware of a platform that requires all 3 arguments to SUBSTRING().

      This seems to only affect queries from the QueryBuilder

      The following DQL works fine:

      UPDATE Common\Model\Location e SET e.path = CONCAT('00010002', SUBSTRING(e.path, 9)) WHERE e.path LIKE '00010001%'
      

      Yet the following QueryBuilder expression:

      $substr = $expr->substring('e.' . $this->getPathFieldName(), strlen($oldPath)+1);
      

      results in:

      Missing argument 3 for Doctrine\ORM\Query\Expr::substring()
      

      If I make that argument optional, default null I get the following generated DQL and error:

      "UPDATE Common\Model\Location e SET e.path = CONCAT('00010002', SUBSTRING(e.path, 9, )) WHERE e.path LIKE '00010001%'
      Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 84: Error: Expected Literal, got ')'
      

        Activity

        Show
        David Abdemoulaie added a comment - Fixed in http://github.com/doctrine/doctrine2/commit/ece0e3ad881fae4b0cb434aaa6257cdc5da6f5fc

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            David Abdemoulaie
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: