Package org.nutz.dao.util.cri

Examples of org.nutz.dao.util.cri.SqlExpression


  }

  @Test
  public void test_like_in() {
    int[] ages = {4, 7, 9};
    SqlExpression e = Cnd.exps("age", ">", 35).and("id", "<", 47);
    SqlExpression e2 = Cnd.exps("name", "\tLIKE ", "%t%").and("age", "IN  \n\r", ages).or(e);
    Condition c = Cnd.where("id", "=", 37).and(e).or(e2).asc("age").desc("id");
    String exp = "WHERE wid=37 AND (age>35 AND wid<47) OR (wname LIKE '%t%' AND age IN (4,7,9) OR (age>35 AND wid<47)) ORDER BY age ASC, wid DESC";
    assertEquals(exp, c.toSql(en).trim());
  }
View Full Code Here


    }

    @Test
    public void test_like_in() {
        int[] ages = {4, 7, 9};
        SqlExpression e = Cnd.exps("age", ">", 35).and("id", "<", 47);
        SqlExpression e2 = Cnd.exps("name", "\tLIKE ", "%t%").and("age", "IN  \n\r", ages).or(e);
        Condition c = Cnd.where("id", "=", 37).and(e).or(e2).asc("age").desc("id");
        String exp = "WHERE wid=37 AND (age>35 AND wid<47) OR (wname LIKE '%t%' AND age IN (4,7,9) OR (age>35 AND wid<47)) ORDER BY age ASC, wid DESC";
        assertEquals(exp, c.toSql(en).trim());
    }
View Full Code Here

        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_add_other_or_method_by_github_issuse_148() {
        SqlExpression e1 = Cnd.exps("city", "=", "beijing").or("city", "=", "shanghai").or("city", "=", "guangzhou").or("city", "=", "shenzhen");
        SqlExpression e2 = Cnd.exps("age", ">", 18).and("age", "<", 30);
        String exp = "WHERE (ct='beijing' OR ct='shanghai' OR ct='guangzhou' OR ct='shenzhen') AND (age>18 AND age<30)";
        assertEquals(exp, Cnd.where(e1).and(e2).toSql(en).trim());
    }
View Full Code Here

    }

    @Test
    public void test_like_in() {
        int[] ages = {4, 7, 9};
        SqlExpression e = Cnd.exps("age", ">", 35).and("id", "<", 47);
        SqlExpression e2 = Cnd.exps("name", "\tLIKE ", "%t%")
                              .and("age", "IN  \n\r", ages)
                              .or(e);
        Condition c = Cnd.where("id", "=", 37)
                         .and(e)
                         .or(e2)
View Full Code Here

        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_add_other_or_method_by_github_issuse_148() {
        SqlExpression e1 = Cnd.exps("city", "=", "beijing")
                              .or("city", "=", "shanghai")
                              .or("city", "=", "guangzhou")
                              .or("city", "=", "shenzhen");
        SqlExpression e2 = Cnd.exps("age", ">", 18).and("age", "<", 30);
        String exp = "WHERE (ct='beijing' OR ct='shanghai' OR ct='guangzhou' OR ct='shenzhen') AND (age>18 AND age<30)";
        assertEquals(exp, Cnd.where(e1).and(e2).toSql(en).trim());
    }
View Full Code Here

TOP

Related Classes of org.nutz.dao.util.cri.SqlExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.