Skip to content

Commit 9028bba

Browse files
committed
Fix test usage of alias and add new test for RawSql key value pair
1 parent e831c46 commit 9028bba

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/system/Database/Live/UpdateTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,38 @@ public function testRawSqlConstraint()
475475

476476
$builder = $this->db->table('user');
477477

478-
$builder->setData($data, true, 'db_myalias')
478+
$builder->setData($data, true, 'myalias')
479479
->updateFields('name, country')
480480
->onConstraint(new RawSql($this->db->protectIdentifiers('user.email') . ' = ' . $this->db->protectIdentifiers('myalias.email')))
481481
->updateBatch();
482482

483483
$this->seeInDatabase('user', ['email' => '[email protected]', 'country' => 'Germany']);
484484
}
485485

486+
public function testRawSqlConstraintWithKey()
487+
{
488+
if ($this->db->DBDriver === 'SQLite3' && ! (version_compare($this->db->getVersion(), '3.33.0') >= 0)) {
489+
$this->markTestSkipped('Only SQLite 3.33 and newer can complete this test.');
490+
}
491+
492+
$data = [
493+
[
494+
'name' => 'Derek Jones',
495+
'email' => '[email protected]',
496+
'country' => 'Germany',
497+
],
498+
];
499+
500+
$builder = $this->db->table('user');
501+
502+
$builder->setData($data, true, 'myalias')
503+
->updateFields('name, country')
504+
->onConstraint(['email' => new RawSql($this->db->protectIdentifiers('myalias.email'))])
505+
->updateBatch();
506+
507+
$this->seeInDatabase('user', ['email' => '[email protected]', 'country' => 'Germany']);
508+
}
509+
486510
public function testNoConstraintFound()
487511
{
488512
$jobData = [

0 commit comments

Comments
 (0)