Skip to content

Commit

Permalink
Merge pull request #4410 from morozov/remove-named-param-colon-prefix
Browse files Browse the repository at this point in the history
Remove support for colon prefix in statement parameters
  • Loading branch information
morozov authored Nov 5, 2020
2 parents 1a9da6d + 403b27f commit f91860d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 31 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Upgrade to 3.0

## BC BREAK: leading in named parameter names not supported

The usage of the colon prefix when binding named parameters is no longer supported.

## BC BREAK `Doctrine\DBAL\Abstraction\Result` removed

The `Doctrine\DBAL\Abstraction\Result` interface is removed. Use the `Doctrine\DBAL\Result` class instead.
Expand Down
5 changes: 0 additions & 5 deletions src/SQLParserUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,6 @@ private static function extractParam($paramName, $paramsOrTypes, $isParam, $defa
return $paramsOrTypes[$paramName];
}

// Hash keys can be prefixed with a colon for compatibility
if (array_key_exists(':' . $paramName, $paramsOrTypes)) {
return $paramsOrTypes[':' . $paramName];
}

if ($defaultValue !== null) {
return $defaultValue;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Driver/OCI8/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function queryConversionProvider(): iterable
],
'named' => [
'SELECT :COL COL1 FROM DUAL',
[':COL' => 1],
['COL' => 1],
['COL1' => 1],
],
'literal-with-placeholder' => [
Expand Down
34 changes: 9 additions & 25 deletions tests/SQLParserUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,42 +474,26 @@ public static function dataExpandListParameters(): iterable
[1, 2, 'bar'],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
],
'Params/types with colons' => [
'Named parameters and partially implicit types' => [
'SELECT * FROM Foo WHERE foo = :foo OR bar = :bar',
[':foo' => 'foo', ':bar' => 'bar'],
[':foo' => ParameterType::INTEGER],
['foo' => 'foo', 'bar' => 'bar'],
['foo' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ? OR bar = ?',
['foo', 'bar'],
[ParameterType::INTEGER, ParameterType::STRING],
],
[
'Named parameters and explicit types' => [
'SELECT * FROM Foo WHERE foo = :foo OR bar = :bar',
[':foo' => 'foo', ':bar' => 'bar'],
[':foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER],
['foo' => 'foo', 'bar' => 'bar'],
['foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ? OR bar = ?',
['foo', 'bar'],
[ParameterType::INTEGER, ParameterType::INTEGER],
],
[
'SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar',
[':foo' => [1, 2], ':bar' => 'bar'],
['foo' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ?',
[1, 2, 'bar'],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
],
[
'SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar',
['foo' => [1, 2], 'bar' => 'bar'],
[':foo' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ?',
[1, 2, 'bar'],
[ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
],
'Null valued parameters (DBAL-522)' => [
'INSERT INTO Foo (foo, bar) values (:foo, :bar)',
['foo' => 1, 'bar' => null],
[':foo' => ParameterType::INTEGER, ':bar' => ParameterType::NULL],
['foo' => ParameterType::INTEGER, 'bar' => ParameterType::NULL],
'INSERT INTO Foo (foo, bar) values (?, ?)',
[1, null],
[ParameterType::INTEGER, ParameterType::NULL],
Expand All @@ -524,8 +508,8 @@ public static function dataExpandListParameters(): iterable
],
'Escaped single quotes SQL- and C-Style (DBAL-1205)' => [
"SELECT * FROM Foo WHERE foo = :foo||''':not_a_param''\\'' OR bar = ''':not_a_param''\\'':bar",
[':foo' => 1, ':bar' => 2],
[':foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER],
['foo' => 1, 'bar' => 2],
['foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ?||\'\'\':not_a_param\'\'\\\'\' OR bar = \'\'\':not_a_param\'\'\\\'\'?',
[1, 2],
[ParameterType::INTEGER, ParameterType::INTEGER],
Expand Down

0 comments on commit f91860d

Please sign in to comment.