mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2844: Doctrine\ORM\Query\QueryException raised when using Criteria object with more than one condition in repository. #3550
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 @doctrinebot on GitHub (Dec 7, 2013).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user yanakey:
@doctrinebot commented on GitHub (Dec 14, 2013):
Comment created by cordoval:
so I have reproduced the problem https://github.com/cordoval/symfony-standard/pull/8/files
what i think is happening is problem lies on Criteria api not being able to handle well multiple parameters in expression
it tries to figure out a name and fails to name them properly on parameters internal property.
I am working on a fix.
@doctrinebot commented on GitHub (Dec 14, 2013):
Comment created by cordoval:
writing failing test first at QueryBuilderTest::testAddCriteriaWhere() here https://github.com/doctrine/doctrine2/pull/874
now working on seeing why that commit in the description may have not solved these other cases
@doctrinebot commented on GitHub (Dec 14, 2013):
Comment created by cordoval:
this should be closed as it is working on master :)
@doctrinebot commented on GitHub (Dec 14, 2013):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-874] was closed:
https://github.com/doctrine/doctrine2/pull/874
@doctrinebot commented on GitHub (Dec 14, 2013):
Comment created by @beberlei:
@doctrinebot commented on GitHub (Dec 14, 2013):
Comment created by @ocramius:
As [~cordoval] said, this seems to be a non-issue. I provided tests to validate that at https://github.com/doctrine/doctrine2/pull/875
@doctrinebot commented on GitHub (Dec 14, 2013):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-875] was closed:
https://github.com/doctrine/doctrine2/pull/875
@doctrinebot commented on GitHub (Dec 14, 2013):
Comment created by @ocramius:
Tests provided at
ce914bef3f@doctrinebot commented on GitHub (Dec 14, 2013):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Jun 3, 2014):
Comment created by althaus:
Stumbled upon this issue today. As this is fixed in master, but not in the 2.4.1 or 2.4.2 release... is this expected to be part of another 2.4.x or only 2.5 as it's just a "unsupported case" and no bug? Would be great if someone could updated the "Fix Version/s" as it's definitely not resolved in 2.4.1.
@doctrinebot commented on GitHub (Jun 6, 2014):
Comment created by @ocramius:
[~althaus] do the tests in this issue run on 2.4.x?
@doctrinebot commented on GitHub (Jun 10, 2014):
Comment created by althaus:
[~ocramius], which tests do you mean exactly?
Comparing the
Doctrine\ORM\Query\QueryExpressionVisitorof the just released 2.4.3 and master the 2.4.x branch is still missing the fix.@leobedrosian commented on GitHub (Nov 8, 2017):
Just ran into this myself. The problem is with the parameter binding logic in
Doctrine\ORM\Query\QueryExpressionVisitor. ThewalkComparisonmethod does not properly handle parameter naming such that parameters are assigned unique names to which the right values can be bound. Instead, the same parameter names are being used/reused and overwritten with each condition on the same column. This is definitely fixed in the master branch (currently v2.5) but the problem exists in 2.4.The simplest solution is to add an incremental, numerical suffix to parameter names based on the number of parameters defined so that every single parameter is assured to be unique for value binding purposes. Ex (line 137):
$parameterName = str_replace('.', '_', $comparison->getField()) . count($this->parameters);In the master branch (currently v2.5), there's some iteration on parameter names happening to resolve this issue (lines 150 to 155) but this seems needlessly inefficient and overkill:
foreach($this->parameters as $parameter) { if($parameter->getName() === $parameterName) { $parameterName .= '_' . count($this->parameters); break; } }Reference file: https://github.com/doctrine/doctrine2/blob/2.5/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php
@lcobucci commented on GitHub (Nov 21, 2017):
@hbedrosian clarifying one thing:
masterisv2.6.x-devand NOTv2.5,v2.5is on2.5branch (which you referenced correctly).2.4is not supported anymore too.If you have any suggestion on how to improve it, please send a PR 😄