DDC-3939: BC Break in 2.5 Cannot add having condition on a non result variable #4817

Closed
opened 2026-01-22 14:49:55 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 6, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user tkleinhakisa:

Hello,

After upgrading to 2.5.1 the following query does not work anymore:

SELECT COUNT(m.id) as unread, conversation.id FROM Message m INNER JOIN m.conversation conversation LEFT JOIN MessageReading mr WITH mr.conversationId = m.conversation AND mr.user = :user WHERE (mr IS NULL OR m.id > mr.lastRead) AND m.conversation IN(5187, 5186, 5184, 5183, 5171, 5172, 5176, 5150, 5139, 5138) GROUP BY m.conversation

I get the following error:
Cannot add having condition on a non result variable

The change has been introduced by this commit
d9c1782a4f in 2.5.0

It was easily fixed by replacing WHERE (mr IS NULL by WHERE (mr.user IS NULL

Either my query was wrong but doctrine supported it when it was not supposed to be, or it's a break to may be worth mentioning in the upgrade file

Thank you

Originally created by @doctrinebot on GitHub (Oct 6, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user tkleinhakisa: Hello, After upgrading to 2.5.1 the following query does not work anymore: SELECT COUNT(m.id) as unread, conversation.id FROM Message m INNER JOIN m.conversation conversation LEFT JOIN MessageReading mr WITH mr.conversationId = m.conversation AND mr.user = :user WHERE (mr IS NULL OR m.id > mr.lastRead) AND m.conversation IN(5187, 5186, 5184, 5183, 5171, 5172, 5176, 5150, 5139, 5138) GROUP BY m.conversation I get the following error: Cannot add having condition on a non result variable The change has been introduced by this commit https://github.com/doctrine/doctrine2/commit/d9c1782a4f6d46f66e9deb2c375830f9192d4482 in 2.5.0 It was easily fixed by replacing WHERE (mr IS NULL by WHERE (mr.user IS NULL Either my query was wrong but doctrine supported it when it was not supposed to be, or it's a break to may be worth mentioning in the upgrade file Thank you
admin added the Bug label 2026-01-22 14:49:55 +01:00
admin closed this issue 2026-01-22 14:49:55 +01:00
Author
Owner

@fnagel commented on GitHub (Oct 26, 2016):

Seems related to #5680

@fnagel commented on GitHub (Oct 26, 2016): Seems related to #5680
Author
Owner

@pdrosos commented on GitHub (Dec 19, 2016):

Hi,

any news for this one? I need it and I can't use it in my query.

@pdrosos commented on GitHub (Dec 19, 2016): Hi, any news for this one? I need it and I can't use it in my query.
Author
Owner

@beberlei commented on GitHub (Feb 16, 2020):

Fixed https://github.com/doctrine/orm/pull/6328

@beberlei commented on GitHub (Feb 16, 2020): Fixed https://github.com/doctrine/orm/pull/6328
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4817