This commit is contained in:
Looly
2020-05-01 22:20:27 +08:00
parent c697de539f
commit be65a142b4
18 changed files with 173 additions and 75 deletions

View File

@@ -19,4 +19,16 @@ public class SqlBuilderTest {
SqlBuilder builder4 = SqlBuilder.create().select().from("user").where(LogicalOperator.AND, new Condition("name", "is not null"));
Assert.assertEquals("SELECT * FROM user WHERE name IS NOT NULL", builder4.build());
}
@Test
public void orderByTest(){
SqlBuilder builder = SqlBuilder.create().select("id", "username").from("user")
.join("role", SqlBuilder.Join.INNER)
.on("user.id = role.user_id")
.where(new Condition("age", ">=", 18),
new Condition("username", "abc", Condition.LikeType.Contains)
).orderBy(new Order("id"));
Assert.assertEquals("SELECT id,username FROM user INNER JOIN role ON user.id = role.user_id WHERE age >= ? AND username LIKE ? ORDER BY id", builder.build());
}
}