Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding parameters optimisation for BackedEnum (array of BackedEnum values) #11319

Open
AlexMinaev19 opened this issue Feb 29, 2024 · 0 comments

Comments

@AlexMinaev19
Copy link

AlexMinaev19 commented Feb 29, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant