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