fix db bug

This commit is contained in:
Looly
2021-04-13 15:04:19 +08:00
parent 56e32846cd
commit 97e15f8152
4 changed files with 101 additions and 68 deletions

View File

@@ -21,7 +21,7 @@ public class DbTest {
List<Entity> find = Db.use().query("select * from user where age = ?", 18);
Assert.assertEquals("王五", find.get(0).get("name"));
}
@Test
public void findTest() throws SQLException {
List<Entity> find = Db.use().find(Entity.create("user").set("age", 18));
@@ -39,7 +39,7 @@ public class DbTest {
@Test
public void pageTest2() throws SQLException {
String sql = "select * from user";
String sql = "select * from user order by name";
// 测试数据库中一共4条数据第0页有3条第1页有1条
List<Entity> page0 = Db.use().page(
sql, Page.of(0, 3));
@@ -56,6 +56,12 @@ public class DbTest {
Assert.assertEquals(4, count);
}
@Test
public void countTest2() throws SQLException {
final long count = Db.use().count("select * from user order by name DESC");
Assert.assertEquals(4, count);
}
@Test
public void findLikeTest() throws SQLException {
// 方式1
@@ -74,7 +80,7 @@ public class DbTest {
@Test
public void findByTest() throws SQLException {
List<Entity> find = Db.use().findBy("user",
Condition.parse("age", "> 18"),
Condition.parse("age", "> 18"),
Condition.parse("age", "< 100")
);
for (Entity entity : find) {
@@ -82,7 +88,7 @@ public class DbTest {
}
Assert.assertEquals("unitTestUser", find.get(0).get("name"));
}
@Test
@Ignore
public void txTest() throws SQLException {