[PR #11053] Handle ENUM Primary Key in ObjectHydrator.php #12778

Closed
opened 2026-01-22 16:15:08 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/11053

State: closed
Merged: No


Where App\Core\Nomenclature\Country is an ENUM used as a Primary Key of a relation, so it tries to cast it to string -- should be simple enough to reproduce, I an not allowed proper time to create a proper PR with tests and all

I've fixed it on our end by copying the source file and applying the same patch, I hope this helps

Error:
Object of class App\Core\Nomenclature\Country could not be converted to string

at vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1903
at Doctrine\ORM\UnitOfWork->tryGetByIdHash(object(Country), 'App\Core\Entity\Location\CountryGroupCountry')
(vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:304)
at Doctrine\ORM\Internal\Hydration\ObjectHydrator->getEntityFromIdentityMap('App\Core\Entity\Location\CountryGroupCountry', array('id' => object(Country)))
(vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:403)

**Original Pull Request:** https://github.com/doctrine/orm/pull/11053 **State:** closed **Merged:** No --- Where `App\Core\Nomenclature\Country` is an ENUM used as a Primary Key of a relation, so it tries to cast it to string -- should be simple enough to reproduce, I an not allowed proper time to create a proper PR with tests and all I've fixed it on our end by copying the source file and applying the same patch, I hope this helps Error: Object of class App\Core\Nomenclature\Country could not be converted to string at vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1903 at Doctrine\ORM\UnitOfWork->tryGetByIdHash(object(Country), 'App\\Core\\Entity\\Location\\CountryGroupCountry') (vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:304) at Doctrine\ORM\Internal\Hydration\ObjectHydrator->getEntityFromIdentityMap('App\\Core\\Entity\\Location\\CountryGroupCountry', array('id' => object(Country))) (vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:403)
admin added the pull-request label 2026-01-22 16:15:08 +01:00
admin closed this issue 2026-01-22 16:15:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#12778