mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1074: NativeQuery with identical but separate tables maps results to incorrect entities #1345
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 21, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user jhartikainen:
Set up:
Steps:
Expected:
Actual:
Notes:
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by jhartikainen:
You can bug me (zomg) on IRC if you need any more data on this
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by @beberlei:
Do you generate the same type of entity from both queries? What about IDs, are they the same from the different tables?
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by jhartikainen:
Entity type is same for both. And yes, the ID's for this case are actually the same in both tables now that I checked.
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by @beberlei:
Then the second query realizes after execution the entities are already in the identity map and returns the already hydrated ones.
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by jhartikainen:
I suspected it might be doing something like that, although it didn't occur to me to confirm the ID's or such..
I wonder if this should be regarded as a bug or not? This kind of a multi-table scenario isn't too common (at least I hope it isn't) so I don't know whether it should work like this or not
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by @beberlei:
Well, what do you think the default behavior should be? I think you can easily solve this by creating two entities "Foo" and "FooArchive" that extend from a mapped superclass, or guarantee that the ids are unique accross all the tables.
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by jhartikainen:
In this case the issue isn't as straighforward as that. The table names are actually dynamically read from another table (don't ask, not my design :D ), so I can't define different entities for them like that.
I think defining the table to be used on-the-fly like this should be supported, but it does sound like a lot of work to be implemented.
I can work around this relatively easily and since it sounds to me like this is caused inherently by how Doctrine handles identifying specific records, perhaps this should be a feature request rather than a bug.
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by @beberlei:
Well Doctrine assumes that all entities come from exactly one table. If the tables are dynamically generated you could at least make sure that they have IDs in certain "ranges", i.e. 1-100000, 100001-200000 and so on to fix this. Or just dont use Object Hydrator if this is possible :)
@doctrinebot commented on GitHub (Mar 21, 2011):
Comment created by jhartikainen:
Yeah in this case it would seem that I'll just need to manually hydrate based on array results. Luckily there's not that many queries which require this.
@doctrinebot commented on GitHub (Mar 27, 2011):
Comment created by @beberlei:
Not an issue.
@doctrinebot commented on GitHub (Mar 27, 2011):
Issue was closed with resolution "Invalid"