Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.1.1
-
Fix Version/s: 2.1.5
-
Component/s: None
-
Security Level: All
-
Labels:None
Description
Named parameters appears to be treated as ordered parameters, when using PARAM_INT_ARRAY or PARAM_STR_ARRAY:
$query = $em->createQuery('
SELECT f FROM Foo f
WHERE a = :a
AND b IN (:b)
');
$query->setParameters(array(
'b' => array(1,2,3),
'a' => 1,
));
Notice that in the query the parameter :a appears before :b. And I call ->setParameters() with :b before :a.
When running this, I get an error from Doctrine/DBAL/SQLParserUtils::expandListParameters:119 saying that the second parameter of array_merge() is not an array.
When setting the parameters in the same order than they appear in the query, it works:
$query->setParameters(array(
'a' => 1,
'b' => array(1,2,3),
));
This is unexpected, as I'm using named parameters; the order should not matter.
Activity
arnaud-lb
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
I have an error in this query: {code} $query = $em->createQuery(' SELECT f FROM Foo f WHERE a = :a AND b IN (:b) '); $query->setParameters(array( 'b' => array(1,2,3), 'a' => 1, )); {code} Notice that in the query the parameter :a is before :b; and I set :b before setting :a. When running this, I get an error from [Doctrine/DBAL/SQLParserUtils::expandListParameters:119|https://github.com/doctrine/dbal/blob/2a44c94b9b15de446ecdff3ee8581c5d56f6ed3e/lib/Doctrine/DBAL/SQLParserUtils.php#L119] saying that the second parameter of array_merge() is not an array. When setting the parameters in the same order than they appear in the query, it works: {code} $query->setParameters(array( 'a' => 1, 'b' => array(1,2,3), )); {code} |
Named parameters appears to be treated as ordered parameters, when using PARAM_INT_ARRAY or PARAM_STR_ARRAY: {code} $query = $em->createQuery(' SELECT f FROM Foo f WHERE a = :a AND b IN (:b) '); $query->setParameters(array( 'b' => array(1,2,3), 'a' => 1, )); {code} Notice that in the query the parameter :a appears before :b. And I call ->setParameters() with :b before :a. When running this, I get an error from [Doctrine/DBAL/SQLParserUtils::expandListParameters:119|https://github.com/doctrine/dbal/blob/2a44c94b9b15de446ecdff3ee8581c5d56f6ed3e/lib/Doctrine/DBAL/SQLParserUtils.php#L119] saying that the second parameter of array_merge() is not an array. When setting the parameters in the same order than they appear in the query, it works: {code} $query->setParameters(array( 'a' => 1, 'b' => array(1,2,3), )); {code} This is unexpected, as I'm using named parameters; the order should not matter. |
Benjamin Eberlei
made changes -
| Project | Doctrine 2 - ORM [ 10032 ] | Doctrine DBAL [ 10040 ] |
| Key | DDC-1372 |
|
Patrick Schwisow
made changes -
| Affects Version/s | 2.1.1 [ 10156 ] |
Benjamin Eberlei
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.1.4 [ 10167 ] | |
| Resolution | Fixed [ 1 ] |
Benjamin Eberlei
made changes -
| Workflow | jira [ 13013 ] | jira-feedback2 [ 17751 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 17751 ] | jira-feedback3 [ 20106 ] |
This list may be incomplete, as errors occurred whilst retrieving source from linked applications:
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-171, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
I'm getting this issue too.
Doctrine\ORM\Query::_doExecute() does a ksort on $sqlParams, but does not sort $types. Doctrine\DBAL\SQLParserUtils::expandListParameters() assumes that $params and $types are in the same order.
As a workaround, I added ksort($types) in _doExecute(), but I'm not sure if this is the proper way to handle this.