mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[feature request]: allow enum instances to be used as parameters in queries. #6942
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 @azjezz on GitHub (Mar 5, 2022).
Feature Request
Summary
As of version 2.9, native support for enums has been added ( https://www.doctrine-project.org/2021/05/24/orm2.9.html ), allow for the following:
one of the limitation with enums is that they are not supported by the query builder.
The following code, results in an
Errorwith messageObject of class App\Entity\Enum\ArticleStatus could not be converted to stringTo get around this problem, you would need to use the enum value instead of the enum instance as follow:
While the fix is trivial, it is quite annoying as i tend to forget about it all the time.
This issue suggests a new feature to be added to the ORM Query builder, where if a parameter is of type
BackedEnum,BackedEnum::$valuewould be used as value instead of attempting to convert the instance to a string, this should not cause any BC breaks.@derrabus commented on GitHub (Mar 6, 2022):
Duplicate of #9372