Skip to content

Commit

Permalink
Merge pull request #237 from roverwolf/DBAL-398
Browse files Browse the repository at this point in the history
DBAL-398: Do not treat assignment operator as a parameter
  • Loading branch information
beberlei committed Dec 22, 2012
2 parents 6ace93c + 8bc32cf commit 2802d88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/SQLParserUtils.php
Expand Up @@ -54,7 +54,7 @@ static public function getPlaceholderPositions($statement, $isPositional = true)
$stmtLen = strlen($statement);
$paramMap = array();
for ($i = 0; $i < $stmtLen; $i++) {
if ($statement[$i] == $match && !$inLiteral) {
if ($statement[$i] == $match && !$inLiteral && ($isPositional || $statement[$i+1] != '=')) {
// real positional parameter detected
if ($isPositional) {
$paramMap[$count] = $i;
Expand Down Expand Up @@ -180,4 +180,4 @@ static public function expandListParameters($query, $params, $types)

return array($query, $paramsOrd, $typesOrd);
}
}
}
2 changes: 2 additions & 0 deletions tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
Expand Up @@ -35,6 +35,8 @@ static public function dataGetPlaceholderPositions()
array('SELECT ":foo" FROM Foo WHERE bar IN (:name1, :name2)', false, array(37 => 'name1', 45 => 'name2')),
array("SELECT ':foo' FROM Foo WHERE bar IN (:name1, :name2)", false, array(37 => 'name1', 45 => 'name2')),
array('SELECT :foo_id', false, array(7 => 'foo_id')), // Ticket DBAL-231
array('SELECT @rank := 1', false, array()), // Ticket DBAL-398
array('SELECT @rank := 1 AS rank, :foo AS foo FROM :bar', false, array(27 => 'foo', 44 => 'bar')), // Ticket DBAL-398
);
}

Expand Down

0 comments on commit 2802d88

Please sign in to comment.