Skip to content

Commit 0900942

Browse files
authored
Merge pull request #2295 from michalsn/set_escape
Test set() method in Builder class more
2 parents 38e686f + 9b9f21e commit 0900942

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

tests/system/Database/Builder/UpdateTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,32 @@ public function testSetWithoutEscape()
289289
$this->assertEquals($expectedSQL, str_replace("\n", ' ', $builder->getCompiledUpdate()));
290290
$this->assertEquals($expectedBinds, $builder->getBinds());
291291
}
292+
293+
//--------------------------------------------------------------------
294+
295+
public function testSetWithAndWithoutEscape()
296+
{
297+
$builder = new BaseBuilder('mytable', $this->db);
298+
299+
$builder->testMode()
300+
->set('foo', 'bar')
301+
->set('field', 'field+1', false)
302+
->where('id', 2)
303+
->update(null, null, null);
304+
305+
$expectedSQL = 'UPDATE "mytable" SET "foo" = \'bar\', field = field+1 WHERE "id" = 2';
306+
$expectedBinds = [
307+
'foo' => [
308+
'bar',
309+
true,
310+
],
311+
'id' => [
312+
2,
313+
true,
314+
],
315+
];
316+
317+
$this->assertEquals($expectedSQL, str_replace("\n", ' ', $builder->getCompiledUpdate()));
318+
$this->assertEquals($expectedBinds, $builder->getBinds());
319+
}
292320
}

0 commit comments

Comments
 (0)