AbstractColumn implements Segment { public ColumnExpression between(Object firstValue, Object secondValue) { return BetweenExpression.between(this, firstValue, secondValue); } AbstractColumn(String name, JDBCType type); abstract String getTableName(BuilderContext helper); String getColumnName(); JDBCType getType(); @Override String build(BuilderContext helper); String getReference(BuilderContext helper); @Override String toString(); ColumnOrder asc(); ColumnOrder desc(); Parameter of(Object value); Parameter of(List<?> values); ParameterDefinition var(); ParameterDefinition inVar(); ColumnExpression equal(Object value); ColumnExpression notEqual(Object value); ColumnExpression greaterThan(Object value); ColumnExpression greaterThanOrEqual(Object value); ColumnExpression lessThan(Object value); ColumnExpression lessThanOrEqual(Object value); ColumnExpression eq(Object value); ColumnExpression neq(Object value); ColumnExpression gt(Object value); ColumnExpression gteq(Object value); ColumnExpression lt(Object value); ColumnExpression lteq(Object value); ColumnExpression between(Object firstValue, Object secondValue); ColumnExpression notBetween(Object firstValue, Object secondValue); ColumnExpression in(List<?> values); ColumnExpression in(T... values); ColumnExpression in(ParameterDefinition def); ColumnExpression in(ParameterDefinition.Builder builder); ColumnExpression in(Parameter inParameter); ColumnExpression notIn(List<?> values); ColumnExpression notIn(ParameterDefinition def); ColumnExpression notIn(ParameterDefinition.Builder builder); ColumnExpression notIn(Parameter inParameter); ColumnExpression like(Object value); ColumnExpression notLike(Object value); ColumnExpression isNull(); ColumnExpression isNotNull(); static final String PERIOD; static final String AS; }
@Test public void testBetween() { AbstractColumn c = column(); assertEquals(getReferName() + " BETWEEN ? AND ?", c.between(value, value).build(bc)); assertBetweenParam(c.between(value, value)); assertFail(c.between(nullValue, value)); assertFail(c.between(nullValue, nullValue)); assertFail(c.between(value, nullValue)); assertBetweenDef(c.between(var("var1"), var("var2")), "var1", "var2", type); try { c.between(var("var1", type2), var("var2")); fail(); }catch (Exception e) {} try { c.between(var("var1"), var("var2", type2)); fail(); }catch (Exception e) {} assertBetweenDef(c.between(VAR, var("var2")), "VAR", "var2", type); assertBetweenDef(c.between(var("var1"), VAR), "var1", "VAR", type); assertBetweenDef(c.between(VAR, VAR), "VAR", "VAR", type); }