Search in sources :

Example 1 with ArrayLikePredicate

use of io.crate.sql.tree.ArrayLikePredicate in project crate by crate.

the class TestStatementBuilder method testArrayLikeExpression.

@Test
public void testArrayLikeExpression() {
    Expression expression = SqlParser.createExpression("'books%' LIKE ANY(race['interests'])");
    assertThat(expression, instanceOf(ArrayLikePredicate.class));
    ArrayLikePredicate arrayLikePredicate = (ArrayLikePredicate) expression;
    assertThat(arrayLikePredicate.inverse(), is(false));
    assertThat(arrayLikePredicate.getEscape(), is(nullValue()));
    assertThat(arrayLikePredicate.getPattern().toString(), is("'books%'"));
    assertThat(arrayLikePredicate.getValue().toString(), is("\"race\"['interests']"));
    expression = SqlParser.createExpression("'b%' NOT LIKE ANY(race)");
    assertThat(expression, instanceOf(ArrayLikePredicate.class));
    arrayLikePredicate = (ArrayLikePredicate) expression;
    assertThat(arrayLikePredicate.inverse(), is(true));
    assertThat(arrayLikePredicate.getEscape(), is(nullValue()));
    assertThat(arrayLikePredicate.getPattern().toString(), is("'b%'"));
    assertThat(arrayLikePredicate.getValue().toString(), is("\"race\""));
}
Also used : ArrayLikePredicate(io.crate.sql.tree.ArrayLikePredicate) SubqueryExpression(io.crate.sql.tree.SubqueryExpression) SubscriptExpression(io.crate.sql.tree.SubscriptExpression) ParameterExpression(io.crate.sql.tree.ParameterExpression) ArrayComparisonExpression(io.crate.sql.tree.ArrayComparisonExpression) Expression(io.crate.sql.tree.Expression) ComparisonExpression(io.crate.sql.tree.ComparisonExpression) NegativeExpression(io.crate.sql.tree.NegativeExpression) Test(org.junit.Test)

Aggregations

ArrayComparisonExpression (io.crate.sql.tree.ArrayComparisonExpression)1 ArrayLikePredicate (io.crate.sql.tree.ArrayLikePredicate)1 ComparisonExpression (io.crate.sql.tree.ComparisonExpression)1 Expression (io.crate.sql.tree.Expression)1 NegativeExpression (io.crate.sql.tree.NegativeExpression)1 ParameterExpression (io.crate.sql.tree.ParameterExpression)1 SubqueryExpression (io.crate.sql.tree.SubqueryExpression)1 SubscriptExpression (io.crate.sql.tree.SubscriptExpression)1 Test (org.junit.Test)1