Search in sources :

Example 26 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testTexts.

@Test
public void testTexts() {
    AbstractFreeSqlBuilder test = create();
    test.append(texts(template, template));
    assertEquals(template + " " + template, test.build());
}
Also used : AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Test(org.junit.Test)

Example 27 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testExpression.

@Test
public void testExpression() throws SQLException {
    Clause test = expression(template);
    AbstractFreeSqlBuilder builder = create();
    builder.append(test);
    builder.setLogicDbName(logicDbName);
    assertEquals(template, test.build());
}
Also used : AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Clause(com.ctrip.platform.dal.dao.sqlbuilder.Clause) Test(org.junit.Test)

Example 28 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testWith.

@Test
public void testWith() {
    AbstractFreeSqlBuilder test = create();
    try {
        test.with(null);
        fail();
    } catch (Exception e) {
    }
    StatementParameters p = new StatementParameters();
    test.with(p);
    // Same is allowed
    test.with(p);
    // Empty is allowed
    p = new StatementParameters();
    test.with(p);
    p.set("", 1, "");
    p = new StatementParameters();
    try {
        test.with(p);
        fail();
    } catch (Exception e) {
    }
}
Also used : StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 29 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testTable.

@Test
public void testTable() {
    AbstractFreeSqlBuilder test = create();
    test.append(table(template));
    assertEquals(wrappedTemplate, test.build());
    test = create();
    test.append(table(tableName));
    test.setHints(new DalHints().inTableShard(1));
    assertEquals("[dal_client_test_1]", test.build());
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Test(org.junit.Test)

Example 30 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testWhere.

@Test
public void testWhere() {
    AbstractFreeSqlBuilder test = create();
    test.where();
    test.setLogicDbName(logicDbName);
    test.setHints(new DalHints());
    assertEquals("WHERE", test.build());
    test = create();
    test.where(template);
    test.setLogicDbName(logicDbName);
    test.setHints(new DalHints());
    assertEquals("WHERE template", test.build());
    test = create();
    test.setLogicDbName(logicDbName);
    test.setHints(new DalHints());
    test.where("count()", template);
    assertEquals("WHERE count() template", test.build());
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Test(org.junit.Test)

Aggregations

AbstractFreeSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder)55 Test (org.junit.Test)51 DalHints (com.ctrip.platform.dal.dao.DalHints)17 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)8 SQLException (java.sql.SQLException)5 Text (com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder.Text)4 ArrayList (java.util.ArrayList)3 Expression (com.ctrip.platform.dal.dao.sqlbuilder.Expressions.Expression)2 Clause (com.ctrip.platform.dal.dao.sqlbuilder.Clause)1