Package org.nutz.dao

Examples of org.nutz.dao.Condition.toSql()


    @Test
    public void test_gt_like() {
        Condition c = Cnd.where("id", ">", 45).and("name", "LIKE", "%ry%");
        String exp = "WHERE wid>45 AND wname LIKE '%ry%'";
        assertEquals(exp, c.toSql(en).trim());
    }

    @Test
    public void test_bracket() {
        Condition c = Cnd.where(Cnd.exps("id", ">", 45)).and("name",
View Full Code Here


    public void test_bracket() {
        Condition c = Cnd.where(Cnd.exps("id", ">", 45)).and("name",
                                                             "LIKE",
                                                             "%ry%");
        String exp = "WHERE (wid>45) AND wname LIKE '%ry%'";
        assertEquals(exp, c.toSql(en).trim());
    }

    @Test
    public void test_order() {
        Condition c = Cnd.orderBy()
View Full Code Here

                         .asc("id")
                         .desc("name")
                         .asc("age")
                         .desc("workingDay");
        String exp = "ORDER BY wid ASC, wname DESC, age ASC, days DESC";
        assertEquals(exp, c.toSql(en).trim());
    }

    @Test
    public void test_like_in() {
        int[] ages = {4, 7, 9};
View Full Code Here

                         .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());
    }

    @Test
    public void test_equel() {
        Condition c = Cnd.where("ff", "=", true);
View Full Code Here

    @Test
    public void test_equel() {
        Condition c = Cnd.where("ff", "=", true);
        String exp = "WHERE ff=true";
        assertEquals(exp, c.toSql(en).trim());
    }

    @Test
    public void test_in_by_int_array() {
        int[] ids = {3, 5, 7};
View Full Code Here

    @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());
    }

    @Test
    public void test_in_by_int_list() {
        List<Integer> list = new ArrayList<Integer>();
View Full Code Here

        list.add(3);
        list.add(5);
        list.add(7);
        Condition c = Cnd.where("id", "iN", list);
        String exp = "WHERE id IN (3,5,7)";
        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_in_by_str_array() {
        Condition c = Cnd.where("nm", "iN", Lang.array("'A'", "B"));
View Full Code Here

    @Test
    public void test_in_by_str_array() {
        Condition c = Cnd.where("nm", "iN", Lang.array("'A'", "B"));
        String exp = "WHERE nm IN ('''A''','B')";
        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_in_by_str_list() {
        List<String> list = new ArrayList<String>();
View Full Code Here

        List<String> list = new ArrayList<String>();
        list.add("'A'");
        list.add("B");
        Condition c = Cnd.where("nm", "iN", list);
        String exp = "WHERE nm IN ('''A''','B')";
        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_is_null() {
        Condition c = Cnd.where("nm", " is ", null);
View Full Code Here

    @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());
    }

    @Test
    public void test_is_not_null() {
        Condition c = Cnd.where("nm", " is nOT ", null);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.