Search in sources :

Example 16 with AbstractFreeSqlBuilder

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

the class AbstractFreeSqlBuilderTest method testSetInWhen.

@Test
public void testSetInWhen() throws SQLException {
    AbstractFreeSqlBuilder test = new AbstractFreeSqlBuilder();
    test.setLogicDbName(logicDbName);
    StatementParameters p = new StatementParameters();
    test.with(p);
    List<String> paras = new ArrayList<>();
    paras.add("abc1");
    paras.add("abc2");
    paras.add("abc3");
    test.select(template).setIn(false, template, paras, Types.VARCHAR);
    assertEquals("SELECT [template]", test.build());
    StatementParameters parameters = test.buildParameters();
    assertEquals(0, parameters.size());
}
Also used : StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) ArrayList(java.util.ArrayList) AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Test(org.junit.Test)

Example 17 with AbstractFreeSqlBuilder

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

the class AbstractFreeSqlBuilderTest method testText.

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

Example 18 with AbstractFreeSqlBuilder

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

the class AbstractFreeSqlBuilderTest method testOrderBy.

@Test
public void testOrderBy() {
    AbstractFreeSqlBuilder test = create();
    test.orderBy(template, true);
    test.setLogicDbName(logicDbName);
    test.setHints(new DalHints());
    assertEquals("ORDER BY " + wrappedTemplate + " ASC", test.build());
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Test(org.junit.Test)

Example 19 with AbstractFreeSqlBuilder

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

the class AbstractFreeSqlBuilderTest method testAppendClauseConditionWithElse.

@Test
public void testAppendClauseConditionWithElse() {
    AbstractFreeSqlBuilder test = create();
    test.appendWhen(true, new Text(template), new Text(elseTemplate));
    assertEquals(template, test.build());
    test = create();
    test.appendWhen(false, new Text(template), new Text(elseTemplate));
    assertEquals(elseTemplate, test.build());
}
Also used : AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Text(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder.Text) Test(org.junit.Test)

Example 20 with AbstractFreeSqlBuilder

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

the class AbstractFreeSqlBuilderTest method testColumns.

@Test
public void testColumns() {
    AbstractFreeSqlBuilder test = create();
    test.append(columns(template, template, template));
    assertEquals("[template] [template] [template]", test.build());
}
Also used : 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