Commit d3456743 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #322 from doctrine/hotfix/DBAL-522-null-parameter-binding

DBAL-522 - SQLParserUtils always throws exceptions on null bound params
parents d69ecc73 bb0ed041
......@@ -212,12 +212,12 @@ class SQLParserUtils
*/
static private function extractParam($paramName, $paramsOrTypes, $isParam, $defaultValue = null)
{
if (isset($paramsOrTypes[$paramName])) {
if (array_key_exists($paramName, $paramsOrTypes)) {
return $paramsOrTypes[$paramName];
}
// Hash keys can be prefixed with a colon for compatibility
if (isset($paramsOrTypes[':' . $paramName])) {
if (array_key_exists(':' . $paramName, $paramsOrTypes)) {
return $paramsOrTypes[':' . $paramName];
}
......
......@@ -286,6 +286,23 @@ SQLDATA
array(1, 2, 'bar'),
array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR)
),
// DBAL-522 - null valued parameters are not considered
array(
'INSERT INTO Foo (foo, bar) values (:foo, :bar)',
array('foo' => 1, 'bar' => null),
array(':foo' => \PDO::PARAM_INT, ':bar' => \PDO::PARAM_NULL),
'INSERT INTO Foo (foo, bar) values (?, ?)',
array(1, null),
array(\PDO::PARAM_INT, \PDO::PARAM_NULL)
),
array(
'INSERT INTO Foo (foo, bar) values (?, ?)',
array(1, null),
array(\PDO::PARAM_INT, \PDO::PARAM_NULL),
'INSERT INTO Foo (foo, bar) values (?, ?)',
array(1, null),
array(\PDO::PARAM_INT, \PDO::PARAM_NULL)
),
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment