DDC-1591: Paginator: ResultVariable cannot be used in HavingClause #1996

Closed
opened 2026-01-22 13:37:03 +01:00 by admin · 11 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 9, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user craue:

Using the QueryBuilder, I'm getting the message

Notice: Undefined index: distance in vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php line 2128

when trying to add a "having" clause for the field "distance", which is defined in the "select" part of the statement:

$queryBuilder
    ->select('myEntity, MY_FUNCTION() AS distance')
    ->having('distance <= 10')
;
Originally created by @doctrinebot on GitHub (Jan 9, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user craue: Using the QueryBuilder, I'm getting the message ``` Notice: Undefined index: distance in vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php line 2128 ``` when trying to add a "having" clause for the field "distance", which is defined in the "select" part of the statement: ``` $queryBuilder ->select('myEntity, MY_FUNCTION() AS distance') ->having('distance <= 10') ; ```
admin added the Bug label 2026-01-22 13:37:03 +01:00
admin closed this issue 2026-01-22 13:37:04 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 14, 2012):

Comment created by @FabioBatSilva:

Christian, I couldn't reproduce.

Can you give more details ?

Thanks.

@doctrinebot commented on GitHub (Jan 14, 2012): Comment created by @FabioBatSilva: Christian, I couldn't reproduce. Can you give more details ? Thanks.
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2012):

Comment created by craue:

I tried it again and found out that it could also be an issue in https://github.com/whiteoctober/Pagerfanta rather in Doctrine itself because my query is passed to that pager to show a sliced result. Maybe that issue could already be resolved by https://github.com/whiteoctober/Pagerfanta/pull/46. Will give it a try...

@doctrinebot commented on GitHub (Jan 15, 2012): Comment created by craue: I tried it again and found out that it could also be an issue in https://github.com/whiteoctober/Pagerfanta rather in Doctrine itself because my query is passed to that pager to show a sliced result. Maybe that issue could already be resolved by https://github.com/whiteoctober/Pagerfanta/pull/46. Will give it a try...
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2012):

Comment created by craue:

In fact, applying that patch made the query work. So this is not a Doctrine issue.

@doctrinebot commented on GitHub (Jan 15, 2012): Comment created by craue: In fact, applying that patch made the query work. So this is not a Doctrine issue.
Author
Owner

@doctrinebot commented on GitHub (Feb 10, 2012):

Comment created by craue:

Since the PR mentioned was not merged and Doctrine's pagination is used now, the issue still exists and I cannot use a result variable in a "having" clause. But I'd like to. ;)

@doctrinebot commented on GitHub (Feb 10, 2012): Comment created by craue: Since the PR mentioned was not merged and Doctrine's pagination is used now, the issue still exists and I cannot use a result variable in a "having" clause. But I'd like to. ;)
Author
Owner

@doctrinebot commented on GitHub (Feb 10, 2012):

Comment created by stof:

This ticket is indeed invalid as it is talking about the query builder. Please open a dedicated ticket for the pagination issue

@doctrinebot commented on GitHub (Feb 10, 2012): Comment created by stof: This ticket is indeed invalid as it is talking about the query builder. Please open a dedicated ticket for the pagination issue
Author
Owner

@doctrinebot commented on GitHub (Feb 10, 2012):

Comment created by craue:

But I am using the QueryBuilder and then passing the query to a DoctrineORMAdapter instance. The error message didn't change, just the line number:

Notice: Undefined index: distance in vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php line 2142

But I can confirm that this error doesn't occur when not using a paginator. How to continue?

@doctrinebot commented on GitHub (Feb 10, 2012): Comment created by craue: But I am using the QueryBuilder and then passing the query to a DoctrineORMAdapter instance. The error message didn't change, just the line number: ``` Notice: Undefined index: distance in vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php line 2142 ``` But I can confirm that this error doesn't occur when not using a paginator. How to continue?
Author
Owner

@doctrinebot commented on GitHub (Feb 10, 2012):

Comment created by @beberlei:

Which paginator are you using?

@doctrinebot commented on GitHub (Feb 10, 2012): Comment created by @beberlei: Which paginator are you using?
Author
Owner

@doctrinebot commented on GitHub (Feb 10, 2012):

Comment created by craue:

Still https://github.com/whiteoctober/Pagerfanta/ ;)

@doctrinebot commented on GitHub (Feb 10, 2012): Comment created by craue: Still https://github.com/whiteoctober/Pagerfanta/ ;)
Author
Owner

@doctrinebot commented on GitHub (Feb 20, 2012):

Comment created by @beberlei:

Renamed and assigned issue.

@doctrinebot commented on GitHub (Feb 20, 2012): Comment created by @beberlei: Renamed and assigned issue.
Author
Owner

@doctrinebot commented on GitHub (Mar 15, 2012):

Comment created by @asm89:

Fixed as sander was kind enough to resubmit the code to the doctrine2 repository now instead:
https://github.com/doctrine/doctrine2/pull/298

@doctrinebot commented on GitHub (Mar 15, 2012): Comment created by @asm89: Fixed as sander was kind enough to resubmit the code to the doctrine2 repository now instead: https://github.com/doctrine/doctrine2/pull/298
Author
Owner

@doctrinebot commented on GitHub (Mar 15, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 15, 2012): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1996