use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testSetWhen.
@Test
public void testSetWhen() {
AbstractFreeSqlBuilder test = new AbstractFreeSqlBuilder();
test.setLogicDbName(logicDbName);
StatementParameters p = new StatementParameters();
test.with(p);
test.select(template).from(template).where(equal(template)).set(false, template, "abc", Types.VARCHAR).when(false);
assertEquals("SELECT [template] FROM [template] WITH (NOLOCK) WHERE", test.build());
StatementParameters parameters = test.buildParameters();
assertEquals(0, parameters.size());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testSelect.
@Test
public void testSelect() {
String noShardTable = "noShard";
AbstractFreeSqlBuilder test = create();
test.select();
test.setLogicDbName(logicDbName);
test.setHints(new DalHints());
assertEquals("SELECT", test.build());
test = create();
test.select(template, template, template);
test.setLogicDbName(logicDbName);
test.setHints(new DalHints());
assertEquals("SELECT [template], [template], [template]", test.build());
test = create();
test.select(text(template), expression(template), column(template).as(template));
test.setLogicDbName(logicDbName);
test.setHints(new DalHints());
assertEquals("SELECT template, template, [template] AS template", test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class ExpressionsTest method setEnv.
private void setEnv(Clause test) {
AbstractFreeSqlBuilder builder = new AbstractFreeSqlBuilder();
builder.append(test);
builder.setLogicDbName(logicDbName);
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testSetHints.
@Test
public void testSetHints() {
AbstractFreeSqlBuilder test = create();
try {
test.setHints(null);
fail();
} catch (Exception e) {
}
test.setHints(new DalHints());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testOr.
@Test
public void testOr() {
AbstractFreeSqlBuilder test = create();
test.or();
assertEquals("", test.build());
test = create();
test.or(template);
assertEquals(template, test.build());
test = create();
test.or(template, template);
assertEquals("template OR template", test.build());
test = create();
test.or(expressions(template));
assertEquals(template, test.build());
test = create();
test.or(expressions(template, expression));
assertEquals(template + " OR " + expression, test.build());
test = create();
test.or(expressions(template, template, template));
assertEquals("template OR template OR template", test.build());
}
Aggregations