diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 3eb0aaaadc86..a7aabc7b97c8 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -737,7 +737,6 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type } else { $keyValue = [(string) $key => $value]; } - $escape = false; } elseif (! is_array($key)) { $keyValue = [$key => $value]; } else { diff --git a/tests/system/Database/Builder/WhereTest.php b/tests/system/Database/Builder/WhereTest.php index 9a5b412adc99..a4b592ffd28c 100644 --- a/tests/system/Database/Builder/WhereTest.php +++ b/tests/system/Database/Builder/WhereTest.php @@ -189,6 +189,21 @@ public function testWhereValueRawSql() $this->assertSame($expected, $sql); } + public function testWhereKeyOnlyRawSql() + { + $sql = $this->db->table('auth_bearer') + ->select('*') + ->where(new RawSql('DATE_ADD(NOW(), INTERVAL 2 HOUR)'), '2023-01-01') + ->getCompiledSelect(true); + + $expected = <<<'SQL' + SELECT * + FROM "auth_bearer" + WHERE DATE_ADD(NOW(), INTERVAL 2 HOUR) = '2023-01-01' + SQL; + $this->assertSame($expected, $sql); + } + public function testWhereKeyAndValueRawSql() { $sql = $this->db->table('auth_bearer')