mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
feat: add ArithmeticQueryColumn and fixed #35
This commit is contained in:
parent
122aefe374
commit
27455f5da7
@ -21,6 +21,7 @@ import com.mybatisflex.core.query.QueryWrapper;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static com.mybatisflex.core.query.QueryMethods.sum;
|
||||||
import static com.mybatisflex.coretest.table.AccountTableDef.ACCOUNT;
|
import static com.mybatisflex.coretest.table.AccountTableDef.ACCOUNT;
|
||||||
|
|
||||||
public class ArithmeticQueryColumnTest {
|
public class ArithmeticQueryColumnTest {
|
||||||
@ -91,6 +92,18 @@ public class ArithmeticQueryColumnTest {
|
|||||||
Assert.assertEquals(sql,"SELECT (`id` + (`id` + 100) * 100) AS `x100` FROM `tb_account`");
|
Assert.assertEquals(sql,"SELECT (`id` + (`id` + 100) * 100) AS `x100` FROM `tb_account`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAdd5() {
|
||||||
|
QueryWrapper query = new QueryWrapper()
|
||||||
|
.select(sum(ACCOUNT.ID.multiply(ACCOUNT.AGE)).as("total_x"))
|
||||||
|
.from(ACCOUNT);
|
||||||
|
|
||||||
|
String sql = toSql(query);
|
||||||
|
System.out.println(sql);
|
||||||
|
|
||||||
|
Assert.assertEquals(sql,"SELECT SUM(`id` * `age`) AS total_x FROM `tb_account`");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSubtract() {
|
public void testSubtract() {
|
||||||
QueryWrapper query = new QueryWrapper()
|
QueryWrapper query = new QueryWrapper()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user