use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testAppendClause.
@Test
public void testAppendClause() {
AbstractFreeSqlBuilder test = create();
test.append(new Text(template));
assertEquals(template, test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testHaving.
@Test
public void testHaving() {
AbstractFreeSqlBuilder test = create();
test.having(template);
test.setLogicDbName(logicDbName);
test.setHints(new DalHints());
assertEquals("HAVING " + template, test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testSetIn.
@Test
public void testSetIn() 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(template, paras, Types.VARCHAR);
assertEquals("SELECT [template]", test.build());
StatementParameters parameters = test.buildParameters();
assertEquals(1, parameters.size());
assertTrue(parameters.get(0).isInParam());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testNotLikePattern.
@Test
public void testNotLikePattern() {
testExpression(wrappedTemplate + " NOT LIKE ?", new ExpressionProvider() {
public AbstractFreeSqlBuilder createExp() {
return create().notLike(template);
}
public AbstractFreeSqlBuilder createExpWithParameter() {
return create().notLike(template, "abc", MatchPattern.BEGIN_WITH, Types.VARCHAR);
}
public AbstractFreeSqlBuilder createExpWithNullParameter() {
return create().notLike(template, null, MatchPattern.BEGIN_WITH, Types.VARCHAR);
}
});
AbstractFreeSqlBuilder builder = create().notLike(template, "abc", MatchPattern.END_WITH, Types.VARCHAR);
assertEquals("%abc", builder.buildParameters().get(0).getValue());
builder = create().notLike(template, "abc", MatchPattern.BEGIN_WITH, Types.VARCHAR);
assertEquals("abc%", builder.buildParameters().get(0).getValue());
builder = create().notLike(template, "abc", MatchPattern.CONTAINS, Types.VARCHAR);
assertEquals("%abc%", builder.buildParameters().get(0).getValue());
builder = create().notLike(template, "a%b%c", MatchPattern.USER_DEFINED, Types.VARCHAR);
assertEquals("a%b%c", builder.buildParameters().get(0).getValue());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testAnd.
@Test
public void testAnd() {
AbstractFreeSqlBuilder test = create();
test.and();
assertEquals("", test.build());
test = create();
test.and(template);
assertEquals(template, test.build());
test = create();
test.and(template, template);
assertEquals("template AND template", test.build());
test = create();
test.and(expressions(template));
assertEquals("template", test.build());
test = create();
test.and(expressions(template, template));
assertEquals("template AND template", test.build());
test = create();
test.and(expressions(template, template, template));
assertEquals("template AND template AND template", test.build());
}
Aggregations