mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #10920] Allow Partial for Non-Object Hydration #12701
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/10920
State: closed
Merged: No
As mentioned here we can understand partial object hydration is a bad idea that can lead to many issues. So it seems a fine to not support it anymore.
But it's also mentionned that the partial object problem does not apply to methods or queries where you do not retrieve the query result as objects. Examples are: Query#getArrayResult(), Query#getScalarResult(), Query#getSingleScalarResult(), etc.
While trying to update code in a project using partial and array result hydration, for performance reasons, my code is way less clean using Dto (that are always flat objects) or using the mix object and scalar data.
Ex. using partial to get an entity with metadata of file attached (but without the blob content for performance and to avoid unnecessary memory load).
Result:

Using a Dto, it's not possible to create nested objects like that:
I receive an error
[Syntax Error] line 0, col 53: Error: Unexpected 'new'as nested objects are not supported.Using a flat Dto:
I'm forced to type
publicationsasintrather thanCollectionorarrayelse I receive an error.Result:

But in that case the object is duplicated because I should have a collection of publication. I would expect to receive a collection or array of publications in the first object rather than duplicated objects.
Using a mix of object and scalar in query:
I need to name the scalar fields explicitly to avoid ambiguity when fetching data. I also have a multi level root result which seems not as clean as with partial query.
Result:

Here is just one of multiple sample I have in mind. Could you please reconsider the support of partial for non problematic use cases? Thanks
Related commit: https://github.com/doctrine/orm/issues/8471