diff --git a/composer.json b/composer.json index 2a777a15..26c633a0 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "require": { "php": "^8.0", "ext-json": "*", + "ext-mbstring": "*", "ext-pdo": "*", "codeception/codeception": "*@dev" }, diff --git a/src/Codeception/Lib/Driver/Db.php b/src/Codeception/Lib/Driver/Db.php index b5680459..e83df570 100755 --- a/src/Codeception/Lib/Driver/Db.php +++ b/src/Codeception/Lib/Driver/Db.php @@ -290,11 +290,13 @@ public function executeQuery($query, array $params): PDOStatement $i = 0; foreach ($params as $param) { ++$i; - if (is_bool($param)) { + if (is_null($param)) { + $type = PDO::PARAM_NULL; + } elseif (is_bool($param)) { $type = PDO::PARAM_BOOL; } elseif (is_int($param)) { $type = PDO::PARAM_INT; - } elseif ($this->isBinary($param)) { + } elseif (is_string($param) && $this->isBinary($param)) { $type = PDO::PARAM_LOB; } else { $type = PDO::PARAM_STR; diff --git a/tests/unit/Codeception/Module/Db/AbstractDbTest.php b/tests/unit/Codeception/Module/Db/AbstractDbTest.php index f880866b..9bd1e4b2 100644 --- a/tests/unit/Codeception/Module/Db/AbstractDbTest.php +++ b/tests/unit/Codeception/Module/Db/AbstractDbTest.php @@ -69,6 +69,11 @@ public function testSeeInDatabaseWithBinary() $this->module->seeInDatabase('users', ['uuid' => hex2bin('11edc34b01d972fa9c1d0242ac120006')]); } + public function testSeeInDatabaseWithNull() + { + $this->module->seeInDatabase('users', ['uuid' => null]); + } + public function testSeeInDatabase() { $this->module->seeInDatabase('users', ['name' => 'davert']);