mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Entity as a parameter in a Query is not correctly processed to its identifier value #5284
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 @fancyweb on GitHub (Oct 6, 2016).
Hello,
I've just found a problem in the
processParameterValuemethod of theAbstractQueryclass (https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/AbstractQuery.php#L423).If you have an entity as a parameter in a
Query, if theClassMetadataof this entity has not been fetched yet, the entity won't be transformed to its identifier to be used as the parameter in the final generated sql query. This is because thehasMetadataFormethod is used, and this method only check in the already fetchedClassMetadataarray.@Ocramius commented on GitHub (Oct 6, 2016):
@fancyweb ugly, but indeed true. Possibly to be solved in 3.x, when we change the metadata approach completely.
@fancyweb commented on GitHub (Oct 6, 2016):
@Ocramius Couldn't we use the method
getMetadataFormethod in a try catch block instead ?@Ocramius commented on GitHub (Oct 6, 2016):
Yes, that can also be done, and should be simple too, for now. Needs some test case scenarios though: