doctrine / dbal

Doctrine Database Abstraction Layer
https://www.doctrine-project.org/projects/dbal.html
MIT License
9.47k stars 1.34k forks source link

SQLParserUtils::expandListParameters fails to process an array of LOB as an array of params when using findBy #4170

Open nicolas-girod opened 4 years ago

nicolas-girod commented 4 years ago

Bug Report

Q A
BC Break no
Version 2.10.2

Summary

When calling findBy with multiple binary strings, the method SQLParserUtils::expandListParameters fails to recognize that the parameters is an array of LOB (ParameterType::LARGE_OBJECT). This leads to an exception in PDOStatement::execute and a further error when the exception handler tries to format the parameters using bin2hex on an array.

Current behaviour

A driver exception is raised because the DBAL doesn't detect a parameter as being an array which leads to an internal exception in PDO.

The type of the parameter is deduced to be 103 (PARAM_LOB + ARRAY MARKER) which fails to pass the test in SQLParserUtils::expandListParameters (line 147):

if ($type !== Connection::PARAM_INT_ARRAY && $type !== Connection::PARAM_STR_ARRAY) { continue; }

How to reproduce

When using an entity with the PK declared as type ParameterType::LARGE_OBJECT, calling findBy with multiple values will fail.

Expected behaviour

The entities are successfully retrieved. Adding $type !== 103 to the test above fixes the issue.

nicolas-girod commented 4 years ago

Seems to be related to #789 #1077