Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-231

Doctrine\DBAL\SQLParserUtils::getPlaceholderPositions() - regex

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 2.3.3
    • Component/s: None
    • Security Level: All
    • Labels:
      None
    • Environment:
      Fedora-16, Zend Serve CE, PHP 5.3.5

      Description

      Running the following SQL (note the named parameter ":account_id"):
      ===================
      SELECT count('*') as cnt FROM feed f INNER JOIN orders_accounts oa ON oa.order_id = f.feed_id INNER JOIN users u ON u.id = f.user_id WHERE oa.account_id = :account_id AND f.feed_type='order' ORDER BY f.create_date DESC
      ===================

      ends up in a thrown exception.
      This SQL was generated by using the Query Builder

      $qb = $this->_em->getConnection()->createQueryBuilder();
      $qb->select('count(\'*\') as cnt');//I know this is bad
      $qb->from('feed', 'f');
      $qb->innerJoin('f', 'orders_accounts', 'oa', 'oa.order_id = f.feed_id');
      $qb->innerJoin('f', 'users', 'u', 'u.id = f.user_id');
      $qb->where('oa.account_id = :account_id AND f.feed_type=\'order\'');
      $qb->setParameter('account_id', $accountId, \PDO::PARAM_INT);

      $stmt = $qb->execute();
      $res = $stmt->fetchAll(\PDO::FETCH_COLUMN);

      ===================
      string(82) "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'NULL_id' in 'where clause'"
      string(3168) "#0 /var/www/cake_to_zf/library/Doctrine/DBAL/Connection.php(628): PDOStatement->execute()
      #1 /var/www/cake_to_zf/library/Doctrine/DBAL/Query/QueryBuilder.php(185): Doctrine\DBAL\Connection->executeQuery('SELECT count('*...', Array, Array)
      #2 /var/www/cake_to_zf/library/of/doctrine/SqlQueryBuilderPaginatorAdapter.php(69): Doctrine\DBAL\Query\QueryBuilder->execute()
      #3 /var/www/cake_to_zf/library/Zend/Paginator.php(1060): of\doctrine\SqlQueryBuilderPaginatorAdapter->count()
      .......

      Suggested Fix:

      Regex on line 64 in preg_match becomes '#([:a-zA-Z0-9_]

      {1}

      )#'
      Added was an "_" ...

      ===================

        Activity

        Ivo Mandalski created issue -
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.9 [ 10168 ]
        Fix Version/s 2.2.2 [ 10197 ]
        Resolution Fixed [ 1 ]
        Hide
        Benjamin Eberlei added a comment -

        Merged in 2.1.x and 2.2 branches.

        Show
        Benjamin Eberlei added a comment - Merged in 2.1.x and 2.2 branches.
        Benjamin Eberlei made changes -
        Fix Version/s 2.0.9 [ 10168 ]
        Benjamin Eberlei made changes -
        Fix Version/s 2.1.7 [ 10200 ]
        Hide
        Andrew Vit added a comment -

        I already fixed this in my reworking of the SqlParserUtils last month. See pull request and confirm that this issue was fixed there, together with other parsing problems:

        https://github.com/doctrine/dbal/pull/113

        Show
        Andrew Vit added a comment - I already fixed this in my reworking of the SqlParserUtils last month. See pull request and confirm that this issue was fixed there, together with other parsing problems: https://github.com/doctrine/dbal/pull/113
        Benjamin Eberlei made changes -
        Workflow jira [ 13494 ] jira-feedback2 [ 17802 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17802 ] jira-feedback3 [ 20157 ]
        Hide
        Benjamin Eberlei added a comment -

        Fixed in 2.3.3

        Show
        Benjamin Eberlei added a comment - Fixed in 2.3.3
        Benjamin Eberlei made changes -
        Fix Version/s 2.3.3 [ 10328 ]
        Fix Version/s 2.2.2 [ 10197 ]
        Fix Version/s 2.1.7 [ 10200 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-231, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Ivo Mandalski
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: