Search in sources :

Example 11 with Condition

use of org.nutz.dao.Condition in project nutz by nutzam.

the class CndTest method test_is_not_null.

@Test
public void test_is_not_null() {
    Condition c = Cnd.where("nm", " is nOT ", null);
    String exp = "WHERE nm IS NOT NULL";
    assertEquals(exp, c.toSql(null).trim());
}
Also used : Condition(org.nutz.dao.Condition) Test(org.junit.Test)

Example 12 with Condition

use of org.nutz.dao.Condition in project nutz by nutzam.

the class CndTest method test_not_sql_group.

@Test
public void test_not_sql_group() {
    SqlExpression e2 = Cnd.exps("f2", "=", 1);
    SqlExpression e3 = Cnd.exps("f3", "=", 1);
    Condition c = Cnd.where(e2).andNot(e3);
    assertEquals(" WHERE (f2=1) AND NOT (f3=1)", c.toString());
}
Also used : Condition(org.nutz.dao.Condition) SqlExpression(org.nutz.dao.util.cri.SqlExpression) Test(org.junit.Test)

Example 13 with Condition

use of org.nutz.dao.Condition in project nutz by nutzam.

the class CndTest method test_in_by_int_array.

@Test
public void test_in_by_int_array() {
    int[] ids = { 3, 5, 7 };
    Condition c = Cnd.where("id", "iN", ids);
    String exp = "WHERE id IN (3,5,7)";
    assertEquals(exp, c.toSql(null).trim());
}
Also used : Condition(org.nutz.dao.Condition) Test(org.junit.Test)

Example 14 with Condition

use of org.nutz.dao.Condition in project nutz by nutzam.

the class CndTest method test_is_null.

@Test
public void test_is_null() {
    Condition c = Cnd.where("nm", " is ", null);
    String exp = "WHERE nm IS NULL";
    assertEquals(exp, c.toSql(null).trim());
}
Also used : Condition(org.nutz.dao.Condition) Test(org.junit.Test)

Example 15 with Condition

use of org.nutz.dao.Condition in project nutz by nutzam.

the class CndTest method test_not_in.

@Test
public void test_not_in() {
    Condition c = Cnd.where("nm", " Not iN ", new int[] { 1, 2, 3 });
    String exp = "WHERE nm NOT IN (1,2,3)";
    assertEquals(exp, c.toSql(null).trim());
}
Also used : Condition(org.nutz.dao.Condition) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 Condition (org.nutz.dao.Condition)16 SqlExpression (org.nutz.dao.util.cri.SqlExpression)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 Cnd (org.nutz.dao.Cnd)1