mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
ObjectHydrator ignores joined scalar values #5551
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 @SirWaddles on GitHub (May 23, 2017).
Originally assigned to: @Ocramius on GitHub.
I'm trying to fetch a subset of data in some collections, and I'm not really sure how to go about it. The way I had planned was to use an aliased value containing the data I wanted to fetch, so that there was no confusion regarding the collection hydration later on (if you fetch the entity, then the joined entity, then it's collection contents, you probably want the whole collection, not a weird subset)
My query looks like
Ideally hoping to select a result with a list entities right next to the filtered names I was after. (A list of users who have not seen the document)
The problem is that subset_names will only ever contain the last name in the result, despite all of them being in the results from the database.
The offending line seems to be in ObjectHydrator.php which replaces the entry every time it sees a new one.
I looked briefly at filtering collections, which could work but would be really messy in the application I'm trying to build.
Is doctrine meant to just ignore data though?
@Ocramius commented on GitHub (Jun 1, 2017):
Doctrine will de-duplicate based on the root of your selection (
base as ent), so this seems like expected behavior. You seem to want just some scalar values, so I suggest fetching the identifier of thebaseentity, and then you shouldn't have this de-duplication anymore.