mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
test: 测试取相反数的构建。
This commit is contained in:
parent
9d464caf3e
commit
989c20d74b
@ -21,7 +21,9 @@ import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.mybatisflex.core.query.QueryMethods.abs;
|
||||
import static com.mybatisflex.core.query.QueryMethods.column;
|
||||
import static com.mybatisflex.core.query.QueryMethods.negative;
|
||||
import static com.mybatisflex.core.query.QueryMethods.number;
|
||||
import static com.mybatisflex.core.query.QueryMethods.sum;
|
||||
import static com.mybatisflex.coretest.table.AccountTableDef.ACCOUNT;
|
||||
@ -156,5 +158,19 @@ public class ArithmeticQueryColumnTest {
|
||||
Assert.assertEquals("SELECT ABS(-1) + 7 FROM `tb_account`", sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNegative() {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(negative(column("(-1)")))
|
||||
.select(negative(abs(ACCOUNT.AGE)).as("opp"))
|
||||
.select(negative(ACCOUNT.ID.add(ACCOUNT.AGE)))
|
||||
.from(ACCOUNT);
|
||||
|
||||
String sql = queryWrapper.toSQL();
|
||||
|
||||
System.out.println(sql);
|
||||
|
||||
Assert.assertEquals("SELECT -(-1), -ABS(`age`) AS `opp`, -(`id` + `age`) FROM `tb_account`", sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user