beberlei/DoctrineExtensions — Issue #71: isSimpleArithmeticExpression
Author: maoueh
Created: 2012-02-24 22:24:47+00:00
State: open

Hi,

Is the library suppose to work with Doctrine 2.2? If the library doesn't support it at the moment, you can close this issue right away.

If it is suppose to be supported, then I'm facing a problem. I'm using master branch of the library (commit 4ea498a6ca7) and doctrine-common 2.2.1 ([acba5b492d](https://github.com/doctrine/common/commit/acba5b492dccb4d79a2e9e824229d2ebc153b81d)) and doctrine orm 2.2 ([191520439b](https://github.com/doctrine/doctrine2/commit/191520439b61f801cdaabeb1916818e2e52878d0)).

I'm trying to paginate a simple query with this code:

$queryBuilder = $this->_em->createQueryBuilder()
->select('n')
->from('AcmeBundle:Notification', 'n');

$query = $queryBuilder->getQuery();
$count = Paginate::getTotalQueryResults($query);
if ($count == 0) {
return array(
'notifications' => array(),
'pageCount' => 0,
);
}

// Calculate the offset based on the page number and the number of results per page
$offset = ($pageIndex - 1) * $limitPerPage;
$paginateQuery = Paginate::getPaginateQuery($query, $offset, $limitPerPage);
$result = $paginateQuery->getResult();

The variable have those values: `$pageIndex = 1`, `$limitPerPage = 5` and there is exactly one record in the database. Not sure if it is important by I'm using a MySQL database.

The call `$paginateQuery->getResult();` generates an exception: `Call to undefined method Doctrine\ORM\Query\AST\PathExpression::isSimpleArithmeticExpression()`

Here the last 5 calls of the stack trace printed by xdebug (I can post more if you need it):

22	1.0641	5763200	Doctrine\ORM\Query\SqlWalker->walkConditionalFactor() ..\SqlWalker.php:0
23	1.0641	5763216	Doctrine\ORM\Query\SqlWalker->walkConditionalPrimary() ..\SqlWalker.php:1617
24	1.0641	5763216	Doctrine\ORM\Query\AST\InExpression->dispatch()	..\SqlWalker.php:1629
25	1.0641	5763216	Doctrine\ORM\Query\SqlWalker->walkInExpression() ..\InExpression.php:49
26	1.0641	5763216	Doctrine\ORM\Query\SqlWalker->walkArithmeticExpression() ..\SqlWalker.php:1820

Regards,
Matt