mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3628: Embeddable Array Hydration Issue #4455
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?
Originally created by @doctrinebot on GitHub (Mar 19, 2015).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user rj.garcia:
I've stumbled across the doctrine embeddable system, and it's been working great; however, I found an inconsistency with the array hydration.
Attached are my configuration files for my parent object and the embeddable. When doing a simple query to retrieve the parent object and use
getArrayResult, I get the following data structureThis is inconsistent with how normal hydration works where the expected result would be something like
@doctrinebot commented on GitHub (Mar 19, 2015):
Comment created by @ocramius:
This is actually expected behavior, IMO
@doctrinebot commented on GitHub (Mar 19, 2015):
Comment created by @beberlei:
Maybe we could document this, as it is a bit weird. But from my perspective this is ok as well. Everything else is very expensive to implement, not sure if its worth the benefit.
@doctrinebot commented on GitHub (Mar 19, 2015):
Comment created by rj.garcia:
Well, currently, I'm working around the issue with the following function
Personally, as a user of this embeddable's feature, in my specific usage of the embeddables with array hydration, I need them in hierarchal format. I'm not too familiar with the hydration internals, so I can't comment on the difficulty of expanding the embeddable entities into structured hierarchal data
@doctrinebot commented on GitHub (Mar 19, 2015):
Comment created by @ocramius:
[~rj.garcia] is there any reason why you're using array hydration here?
Adding this change to the
ArrayHydratoris actually problematic/complex (and a BC break now, since we froze 2.5.0-beta1 yesterday).I would suggest keeping it out of the ORM.
@doctrinebot commented on GitHub (Mar 19, 2015):
Comment created by rj.garcia:
Yes, I was running into issues with prefetching in my query. Even though I had prefetched all of my desired associations, doctrine was still performing extra queries to load associations that I wasn't using/wanted. After I fetched my main entity collection, I needed to traverse it (perform some changes) and convert to arrays for outputting in a JSON api. When I traversed the object graph, doctrine would run queries on sub entities that I didn't want. When I switched to array hydration, naturally, I didn't get any of those extra queries when I traversed the array structure. I've also found better performance results when using array hydration, and because I'm only querying my entities to export them into JSON, I don't need full data/entity consistency.
Just recently, I stated using embeddables, and that's how I found out about the array hydration difference (because I was already using array hydration).
@doctrinebot commented on GitHub (Mar 19, 2015):
Comment created by @ocramius:
Resolving as
won't fixsince at this point, this is a BC break and is also quite complex/useless to solve from our perspective (we did have some internal discussion about it).@doctrinebot commented on GitHub (Mar 19, 2015):
Issue was closed with resolution "Won't Fix"