Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for colon prefix in statement parameters #4410

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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