Skip to content

Commit a00cb7b

Browse files
W0rmasergeyklay
authored andcommitted
Use proper parameter type for NULL values
1 parent 1858892 commit a00cb7b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Codeception/Lib/Driver/Db.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ public function executeQuery($query, array $params): PDOStatement
290290
$i = 0;
291291
foreach ($params as $param) {
292292
++$i;
293-
if (is_bool($param)) {
293+
if (is_null($param)) {
294+
$type = PDO::PARAM_NULL;
295+
} elseif (is_bool($param)) {
294296
$type = PDO::PARAM_BOOL;
295297
} elseif (is_int($param)) {
296298
$type = PDO::PARAM_INT;

tests/unit/Codeception/Module/Db/AbstractDbTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public function testSeeInDatabaseWithBinary()
6969
$this->module->seeInDatabase('users', ['uuid' => hex2bin('11edc34b01d972fa9c1d0242ac120006')]);
7070
}
7171

72+
public function testSeeInDatabaseWithNull()
73+
{
74+
$this->module->seeInDatabase('users', ['uuid' => null]);
75+
}
76+
7277
public function testSeeInDatabase()
7378
{
7479
$this->module->seeInDatabase('users', ['name' => 'davert']);

0 commit comments

Comments
 (0)