Skip to content

Commit 8fd5cbc

Browse files
committed
Add more tests
1 parent ef83949 commit 8fd5cbc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/WP_SQLite_Driver_Translation_Tests.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,24 @@ public function testUpdate(): void {
179179
'UPDATE `t` SET `c` = 1 WHERE rowid IN ( SELECT rowid FROM `t` ORDER BY `c` ASC LIMIT 1 )',
180180
'UPDATE t SET c = 1 ORDER BY c ASC LIMIT 1'
181181
);
182+
183+
// UPDATE with multiple tables.
184+
$this->assertQuery(
185+
'UPDATE `t1` SET `id` = 1 FROM `t2` WHERE `t1`.`c` = `t2`.`c`',
186+
'UPDATE t1, t2 SET t1.id = 1 WHERE t1.c = t2.c'
187+
);
188+
189+
// UPDATE with JOIN.
190+
$this->assertQuery(
191+
'UPDATE `t1` SET `id` = 1 FROM `t2` WHERE `t1`.`c` = 2 AND `t1`.`c` = `t2`.`c`',
192+
'UPDATE t1 JOIN t2 ON t1.c = t2.c SET t1.id = 1 WHERE t1.c = 2'
193+
);
194+
195+
// UPDATE with JOIN using a derived table.
196+
$this->assertQuery(
197+
'UPDATE `t1` SET `id` = 1 FROM ( SELECT * FROM `t2` ) AS `t2` WHERE `t1`.`c` = 2 AND `t1`.`c` = `t2`.`c`',
198+
'UPDATE t1 JOIN ( SELECT * FROM t2 ) AS t2 ON t1.c = t2.c SET t1.id = 1 WHERE t1.c = 2'
199+
);
182200
}
183201

184202
public function testDelete(): void {

0 commit comments

Comments
 (0)