mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Error with QueryBuilder::setParameter() and associative arrays #7140
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 @alexcmdev on GitHub (Apr 26, 2023).
Bug Report
When passing an associative array to a
QueryBuilder::setParameter()it triggers the errorSQLSTATE[HY093]: Invalid parameter number: parameter was not defined.Summary
Working with pdo_mysql, I'm triggering an error every time I pass an associative array to a QueryBuilder::setParameter(). I don't know if this is the expected behaviour, but I guees it's not, beacuse if the type is specified as Types::ARRAY it works.
As far as I know it may be a problem of the ParameterTypeInferer::inferType() becuase of this:
Current behavior
The next code will trigger an error
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined:whereas this works properly:
How to reproduce
Using the pdo_mysql as database driver, add an associative array to setParameter() without defining the type.
Expected behavior
To infer the type automatically when is an associative array.
@alexcmdev commented on GitHub (Apr 26, 2023):
Maybe is not the type, as setting the type to Types::ARRAY returns the same as findAll.