partials and shared objects between queries #5417

Closed
opened 2026-01-22 15:07:15 +01:00 by admin · 2 comments
Owner

Originally created by @eventhorizonpl on GitHub (Feb 13, 2017).

Originally assigned to: @Ocramius on GitHub.

Hi,

I don't know if it's a bug or optimization feature.

Lets say that I've got a Post entity and User entity.

In one query I do something like this:

->select('partial p.{id,slug,title}, partial pu.{id,username}') ->from('Post', 'p') ->leftJoin('p.user', 'pu')

and I've got another query in the same action and I do something like this

->select('partial u.{id,username,slug}') ->from('User', 'u')

The problem is that in result list of second query I'm getting a 1 user without slug. This object looks like it was taken from Post query.

I guess that it's caused by some internal doctrine optimization. But I don't know if it's a feature or a bug.

Without using partial queries you will not notice any problem.

Best regards,
Michal

Originally created by @eventhorizonpl on GitHub (Feb 13, 2017). Originally assigned to: @Ocramius on GitHub. Hi, I don't know if it's a bug or optimization feature. Lets say that I've got a Post entity and User entity. In one query I do something like this: ` ->select('partial p.{id,slug,title}, partial pu.{id,username}') ->from('Post', 'p') ->leftJoin('p.user', 'pu') ` and I've got another query in the same action and I do something like this ` ->select('partial u.{id,username,slug}') ->from('User', 'u') ` The problem is that in result list of second query I'm getting a 1 user without slug. This object looks like it was taken from Post query. I guess that it's caused by some internal doctrine optimization. But I don't know if it's a feature or a bug. Without using partial queries you will not notice any problem. Best regards, Michal
admin added the BugInvalidQuestion labels 2026-01-22 15:07:15 +01:00
admin closed this issue 2026-01-22 15:07:15 +01:00
Author
Owner

@Ocramius commented on GitHub (Feb 13, 2017):

This is normal, since the partial objects that were hydrated stay in memory after the first query, and won't be re-hydrated.

I suggest taking an alternate approach: https://ocramius.github.io/blog/doctrine-orm-optimization-hydration/

Closing as invalid

@Ocramius commented on GitHub (Feb 13, 2017): This is normal, since the partial objects that were hydrated stay in memory after the first query, and won't be re-hydrated. I suggest taking an alternate approach: https://ocramius.github.io/blog/doctrine-orm-optimization-hydration/ Closing as `invalid`
Author
Owner

@eventhorizonpl commented on GitHub (Feb 13, 2017):

ok, thanks!

@eventhorizonpl commented on GitHub (Feb 13, 2017): ok, thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5417