Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBAL-231: Doctrine\DBAL\SQLParserUtils::getPlaceholderPositions() - regex #1407

Closed
doctrinebot opened this issue Mar 5, 2012 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user ivolator:

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 "_" ...

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Merged in 2.1.x and 2.2 branches.

@doctrinebot
Copy link
Author

Comment created by avit:

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:

#113

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed in 2.3.3

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.3.3 milestone Dec 6, 2015
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants