orm
orm copied to clipboard
Binding parameters optimisation for `BackedEnum` (`array` of `BackedEnum` values)
Feature Request
According to the documentation, we can pass integers, arrays of strings/integers, DateTime instances, and managed entities to the setParameter
method (or to the constructor of Doctrine\ORM\Query\Parameter
class). It's not a full list, because we can pass also BackedEnum
or array
of BackedEnum
values. Doctrine automatically infers which type you are setting as value.
Also, the documentation says the following:
Even though passing DateTime instance is allowed, it impacts performance as by default there is an attempt to load metadata for object, and if it's not found, type is inferred from the original value.
Unfortunately, the current implementation of supporting BackedEnum
as parameters (was added by PR) does not allow specifying the type of parameter manually to make performance optimization. If you try to specify Doctrine\DBAL\Types\Type::STRING
, you get an exception.
Q | A |
---|---|
New Feature | yes |
RFC | yes |
BC Break | no |
Summary
It would be nice to add support for explicitly passing type for BackedEnum
parameters:
-
StringBackedEnum
-Doctrine\DBAL\Types\Type::STRING
-
IntBackedEnum
-Doctrine\DBAL\Types\Type::INTEGER
-
array<array-key, StringBackedEnum>
-Doctrine\DBAL\ArrayParameterType::STRING
-
array<array-key, IntBackedEnum>
-Doctrine\DBAL\ArrayParameterType::INTEGER