mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Criteria with enums to filter lazy loaded collections #7378
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 @kira0269 on GitHub (May 29, 2024).
Bug Report
Summary
Working with enums in matching criteria for collections does not work correctly for bot lazy and eager loading.
Current behavior
When filtering collections with
$collection->matching($criteria), if the collection is not initialized, the values from the criteria object won't be converted to database types. So\BackedEnums are not replaced by their scalar value.How to reproduce
There is the stack trace:
Expected behavior
I expect the same behavior between the two cases.
@kira0269 commented on GitHub (May 29, 2024):
I found a "workaround" in order to make it work: I set the fetch mode to 'EAGER'. This way, the collection is always initialized and the comparison with the enum works.
In my case, it's still acceptable since I don't have too many records to load.
@stof commented on GitHub (Jun 20, 2024):
For anyone wanting to help on that, the support of enum values need to be added in
ManyToManyPersister::loadCriteria@mpdude commented on GitHub (Mar 31, 2025):
Please try #11895