Calling distinct() on QueryBuilder does not update state correctly #7168

Closed
opened 2026-01-22 15:45:57 +01:00 by admin · 5 comments
Owner

Originally created by @macroparts on GitHub (Jun 22, 2023).

Bug Report

Q A
BC Break no
Version 2.14.3

Summary

When calling distinct() on a Query builder after getQuery(), then a subsequent getQuery() would ignore the distinct query part.

Current behavior

See summary

How to reproduce

  1. Use the QueryBuilder and create any non-distinct query.
  2. Call getQuery() on the QueryBuilder
  3. Call distinct() on the QueryBuilder
  4. Call getQuery() on the QueryBuilder again

Expected behavior

The second getQuery() call should return a Query using the distinct keyword.

Originally created by @macroparts on GitHub (Jun 22, 2023). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 2.14.3 #### Summary When calling distinct() on a Query builder after getQuery(), then a subsequent getQuery() would ignore the distinct query part. #### Current behavior See summary #### How to reproduce 1. Use the QueryBuilder and create any non-distinct query. 2. Call getQuery() on the QueryBuilder 3. Call distinct() on the QueryBuilder 4. Call getQuery() on the QueryBuilder again #### Expected behavior The second getQuery() call should return a Query using the distinct keyword.
admin closed this issue 2026-01-22 15:45:57 +01:00
Author
Owner

@greg0ire commented on GitHub (Jun 23, 2023):

Looks like it would be fixed by adding $this->state = self::STATE_DIRTY inside distinct()… are you up to send a PR?

@greg0ire commented on GitHub (Jun 23, 2023): Looks like it would be fixed by adding `$this->state = self::STATE_DIRTY` inside `distinct()`… are you up to send a PR?
Author
Owner

@macroparts commented on GitHub (Jun 23, 2023):

@greg0ire hope I was following your contribution guidelines correctly. I will appreciate a review of my PR.

@macroparts commented on GitHub (Jun 23, 2023): @greg0ire hope I was following your contribution guidelines correctly. I will appreciate a review of my PR.
Author
Owner

@greg0ire commented on GitHub (Jun 23, 2023):

Version | 2.x.x

What version are you using, precisely?

@greg0ire commented on GitHub (Jun 23, 2023): > Version | 2.x.x What version are you using, precisely?
Author
Owner

@macroparts commented on GitHub (Jun 23, 2023):

2.14.3 is currently used in my project and I was hoping to get a fix for that version but I can also aim for an upgrade and submit a fix for 2.15.x

@macroparts commented on GitHub (Jun 23, 2023): 2.14.3 is currently used in my project and I was hoping to get a fix for that version but I can also aim for an upgrade and submit a fix for 2.15.x
Author
Owner

@greg0ire commented on GitHub (Jun 23, 2023):

Please do, 2.14.x is no longer maintained.

@greg0ire commented on GitHub (Jun 23, 2023): Please do, 2.14.x is no longer maintained.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7168