test: 测试 Db + Row 原生 SQL 子查询插入与更新。

This commit is contained in:
Suomm 2024-04-02 15:14:32 +08:00
parent 9a36cff0d8
commit 0e7e49c117

View File

@ -42,6 +42,7 @@ import java.util.Map;
* @author 王帅 * @author 王帅
* @since 2023-10-11 * @since 2023-10-11
*/ */
@SuppressWarnings("all")
public class DbTest { public class DbTest {
@BeforeClass @BeforeClass
@ -140,4 +141,24 @@ public class DbTest {
() -> Db.selectListBySql("select * from tb_account where age > #{age} and id > ?", map, 1)); () -> Db.selectListBySql("select * from tb_account where age > #{age} and id > ?", map, 1));
} }
@Test
public void testRowUpdate() {
Row row = new Row();
row.setRaw("age", QueryWrapper.create()
.select("age")
.from("tb_account")
.where("id = ?", 1));
Assert.assertEquals(1, Db.updateByQuery("tb_account", row, QueryWrapper.create().where("id = ?", 1)));
}
@Test
public void testRowInsert() {
Row row = new Row();
row.setRaw("age", QueryWrapper.create()
.select("age")
.from("tb_account")
.where("id = ?", 1));
Assert.assertEquals(1, Db.insert("tb_account", row));
}
} }