Search in sources :

Example 1 with BetweenPredicate

use of com.blazebit.persistence.parser.predicate.BetweenPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testNotBetweenDate.

@Test
public void testNotBetweenDate() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN a.x NOT BETWEEN {d '1991-05-21'} AND {d '1991-05-22'} THEN 0 ELSE 1 END");
    GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new BetweenPredicate(path("a", "x"), _date(1991, 5, 21), _date(1991, 5, 22), true), _int("0"))), _int("1"));
    assertEquals(expected, result);
}
Also used : BetweenPredicate(com.blazebit.persistence.parser.predicate.BetweenPredicate) Test(org.junit.Test)

Example 2 with BetweenPredicate

use of com.blazebit.persistence.parser.predicate.BetweenPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testNotBetweenString.

@Test
public void testNotBetweenString() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN a.x NOT BETWEEN 'ab' AND 'zb' THEN 0 ELSE 1 END");
    GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new BetweenPredicate(path("a", "x"), _string("ab"), _string("zb"), true), _int("0"))), _int("1"));
    assertEquals(expected, result);
}
Also used : BetweenPredicate(com.blazebit.persistence.parser.predicate.BetweenPredicate) Test(org.junit.Test)

Example 3 with BetweenPredicate

use of com.blazebit.persistence.parser.predicate.BetweenPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testBetweenString.

@Test
public void testBetweenString() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN a.x BETWEEN 'ab' AND 'zb' THEN 0 ELSE 1 END");
    GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new BetweenPredicate(path("a", "x"), _string("ab"), _string("zb")), _int("0"))), _int("1"));
    assertEquals(expected, result);
}
Also used : BetweenPredicate(com.blazebit.persistence.parser.predicate.BetweenPredicate) Test(org.junit.Test)

Example 4 with BetweenPredicate

use of com.blazebit.persistence.parser.predicate.BetweenPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testBetweenDate.

@Test
public void testBetweenDate() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN a.x BETWEEN {d '1991-05-21'} AND {d '1991-05-22'} THEN 0 ELSE 1 END");
    GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new BetweenPredicate(path("a", "x"), _date(1991, 5, 21), _date(1991, 5, 22)), _int("0"))), _int("1"));
    assertEquals(expected, result);
}
Also used : BetweenPredicate(com.blazebit.persistence.parser.predicate.BetweenPredicate) Test(org.junit.Test)

Example 5 with BetweenPredicate

use of com.blazebit.persistence.parser.predicate.BetweenPredicate in project blaze-persistence by Blazebit.

the class BetweenBuilderImpl method andSubqery.

@Override
public SubqueryInitiator<T> andSubqery(String subqueryAlias, String expression) {
    verifySubqueryBuilderEnded();
    SubqueryBuilderListenerImpl<T> superExpressionSubqueryListener = new SuperExpressionSubqueryBuilderListener<T>(subqueryAlias, expressionFactory.createSimpleExpression(expression)) {

        @Override
        public void onBuilderEnded(SubqueryInternalBuilder<T> builder) {
            super.onBuilderEnded(builder);
            predicate = new BetweenPredicate(left, start, superExpression, negated);
            listener.onBuilderEnded(BetweenBuilderImpl.this);
        }
    };
    return startSubqueryInitiator(subqueryInitFactory.createSubqueryInitiator(result, superExpressionSubqueryListener, false, clauseType));
}
Also used : SuperExpressionSubqueryBuilderListener(com.blazebit.persistence.impl.builder.expression.SuperExpressionSubqueryBuilderListener) SubqueryInternalBuilder(com.blazebit.persistence.impl.SubqueryInternalBuilder) BetweenPredicate(com.blazebit.persistence.parser.predicate.BetweenPredicate)

Aggregations

BetweenPredicate (com.blazebit.persistence.parser.predicate.BetweenPredicate)13 Test (org.junit.Test)8 SubqueryInternalBuilder (com.blazebit.persistence.impl.SubqueryInternalBuilder)2 SuperExpressionSubqueryBuilderListener (com.blazebit.persistence.impl.builder.expression.SuperExpressionSubqueryBuilderListener)2 MultipleSubqueryInitiatorImpl (com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl)1 ExpressionBuilder (com.blazebit.persistence.impl.builder.expression.ExpressionBuilder)1 ExpressionBuilderEndedListener (com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener)1 SubqueryExpression (com.blazebit.persistence.parser.expression.SubqueryExpression)1