mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Custom types converted to database value by __toString() in loadAll instead of Type::convertToDatabaseValue() #7354
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 @hlib-kuznetsov on GitHub (Mar 29, 2024).
Originally assigned to: @beberlei on GitHub.
Bug Report
Summary
When eager relations are loaded by
BasicEntityPersister::loadAll()cbb6c897de/src/Persisters/Entity/BasicEntityPersister.php (L907)There only 3 options for array type - STRING, INTEGER and ASCII
cbb6c897de/src/Persisters/Entity/BasicEntityPersister.php (L1908-L1912)So any custom type will be narrowed to one of those types, based on
Type::getBindingType()or will fail.Then when
\Doctrine\DBAL\Connectionbinds values usingType::convertToDatabaseValue()any custom type, including Symfony\Uuid will be converted using STRING, INTEGER or ASCIIconvertToDatabaseValue(), not the type's one.Current behavior
Eager relations refering to custom types are not loaded which leads to additional lazy queries
How to reproduce
Try eager loading when relation refers to column with any custom type, including uuid
Expected behavior
Custom types are bound to statement using
convertToDatabaseValue(), not using__toString()@beberlei commented on GitHub (Mar 31, 2024):
Could this be related to new eager loading of one to many associations?
@michanismus commented on GitHub (Apr 1, 2024):
Same for me and my custom Uuid implementation. Database type is binary and the php type is a string.
Relations with EAGER loading will always return an empty result. The parameter type is string without being converted to real binary database representation.
Last working version for me: 2.16.3
@pauci commented on GitHub (Apr 5, 2024):
I'm affected by this issue too. With database type integer, mapped to custom value object PurchaseId, I'm getting error
Object of class PurchaseId could not be converted to intStuck on 2.16.3
@wiseguy1394 commented on GitHub (Aug 14, 2024):
any progress on this?
@wiseguy1394 commented on GitHub (Aug 14, 2024):
@beberlei https://github.com/doctrine/orm/pull/11573
No idea if it is sufficient.
@janedbal commented on GitHub (Aug 18, 2025):
I believe this I submitted reproduction failing test in https://github.com/doctrine/orm/pull/12130