Skip to content

Commit 172e044

Browse files
committed
Add unit test for the case "$v === null and $k has operator"
For this code path: "elseif (preg_match('/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', $k ..." The above code path "elseif (! $this->hasOperator($k) ..." is covered in testOrWhereInClosure() and testOrWhereNotInClosure().
1 parent 7880563 commit 172e044

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/system/Database/Builder/WhereTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ public function testWhereAssociateArray()
111111
$this->assertSame($expectedBinds, $builder->getBinds());
112112
}
113113

114+
public function testWhereAssociateArrayKeyHasEqualValueIsNull()
115+
{
116+
$builder = $this->db->table('user');
117+
118+
$where = [
119+
'id <' => 100,
120+
'col1 =' => null,
121+
];
122+
123+
$expectedSQL = 'SELECT * FROM "user" WHERE "id" < 100 AND "col1" IS NULL';
124+
$expectedBinds = [
125+
'id' => [
126+
100,
127+
true,
128+
],
129+
];
130+
131+
$builder->where($where);
132+
$this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect()));
133+
$this->assertSame($expectedBinds, $builder->getBinds());
134+
}
135+
114136
public function testWhereCustomString()
115137
{
116138
$builder = $this->db->table('jobs');

0 commit comments

Comments
 (0)