mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-504: HYDRATE_ARRAY doesn't function as expected (like D1) #629
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 (Apr 9, 2010).
Jira issue originally created by user spiffyjr:
HYDRATE_ARRAY doesn't function as I would expect it - that is, it doesn't function like Doctrine 1's HYDRATE_ARRAY. For example,
Gives me the result set (notice username is NOT inside a key of 'user' as would be the case with Doctrine 1)
@doctrinebot commented on GitHub (Apr 9, 2010):
Comment created by spiffyjr:
Sorry, that first query should be:
@doctrinebot commented on GitHub (Apr 10, 2010):
Comment created by @hobodave:
Array hydration is not intended to function like D1.
See:
http://www.doctrine-project.org/documentation/manual/2_0/en/dql-doctrine-query-language#the-query-class:pure-and-mixed-results
and
http://www.doctrine-project.org/documentation/manual/2_0/en/dql-doctrine-query-language#the-query-class:hydration-mode-asumptions:scalar-hydration-details
@doctrinebot commented on GitHub (Apr 10, 2010):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Apr 10, 2010):
Comment created by romanb:
Thats right, this is expected behavior but I can see that the documentation is still not clear enough on that, especially there is no documentation yet for how to actually get partial objects (what you want in your query).
Long story short, in Doctrine 2 "foo.bar" where foo is an entity alias an bar a scalar field of the entity selects a scalar value, not an object. To select a partial object, you need this syntax:
Note that, unlike in D1, the rest of the fields of a partial object can not be loaded lazily, so be careful with partial objects.
@doctrinebot commented on GitHub (Apr 10, 2010):
Comment created by spiffyjr:
Wonderful! I was hoping it was a misinterpretation (or missing altogether) of the docs but I was unable to find anything that said otherwise. I'm LOVING D2, keep up the good work.