Search in sources :

Example 21 with QueryValue

use of jakarta.nosql.query.QueryValue in project jnosql-diana by eclipse.

the class AbstractWhereSupplier method exitIn.

@Override
public void exitIn(QueryParser.InContext ctx) {
    boolean hasNot = Objects.nonNull(ctx.not());
    String name = ctx.name().getText();
    QueryValue<?>[] values = ctx.value().stream().map(ValueConverter::get).toArray(QueryValue[]::new);
    ArrayQueryValue value = DefaultArrayValue.of(values);
    checkCondition(new DefaultCondition(name, IN, value), hasNot);
}
Also used : ConditionQueryValue(jakarta.nosql.query.ConditionQueryValue) QueryValue(jakarta.nosql.query.QueryValue) ArrayQueryValue(jakarta.nosql.query.ArrayQueryValue) StringQueryValue(jakarta.nosql.query.StringQueryValue) ArrayQueryValue(jakarta.nosql.query.ArrayQueryValue)

Example 22 with QueryValue

use of jakarta.nosql.query.QueryValue in project jnosql-diana by eclipse.

the class FindByMethodQueryProviderTest method shouldReturnParserQuery27.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeBetween" })
public void shouldReturnParserQuery27(String query) {
    Operator operator = Operator.BETWEEN;
    String entity = "entity";
    SelectQuery selectQuery = queryProvider.apply(query, entity);
    assertNotNull(selectQuery);
    assertEquals(entity, selectQuery.getEntity());
    assertTrue(selectQuery.getFields().isEmpty());
    assertTrue(selectQuery.getOrderBy().isEmpty());
    assertEquals(0, selectQuery.getLimit());
    assertEquals(0, selectQuery.getSkip());
    Optional<Where> where = selectQuery.getWhere();
    assertTrue(where.isPresent());
    Condition condition = where.get().getCondition();
    QueryValue<?> value = condition.getValue();
    assertEquals(operator, condition.getOperator());
    QueryValue<?>[] values = MethodArrayValue.class.cast(value).get();
    ParamQueryValue param1 = (ParamQueryValue) values[0];
    ParamQueryValue param2 = (ParamQueryValue) values[1];
    assertNotEquals(param2.get(), param1.get());
}
Also used : Operator(jakarta.nosql.query.Operator) SelectQuery(jakarta.nosql.query.SelectQuery) Condition(jakarta.nosql.query.Condition) ParamQueryValue(jakarta.nosql.query.ParamQueryValue) Where(jakarta.nosql.query.Where) ParamQueryValue(jakarta.nosql.query.ParamQueryValue) ConditionQueryValue(jakarta.nosql.query.ConditionQueryValue) QueryValue(jakarta.nosql.query.QueryValue) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

QueryValue (jakarta.nosql.query.QueryValue)22 ArrayQueryValue (jakarta.nosql.query.ArrayQueryValue)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 ValueSource (org.junit.jupiter.params.provider.ValueSource)18 StringQueryValue (jakarta.nosql.query.StringQueryValue)15 NumberQueryValue (jakarta.nosql.query.NumberQueryValue)14 ParamQueryValue (jakarta.nosql.query.ParamQueryValue)9 ConditionQueryValue (jakarta.nosql.query.ConditionQueryValue)7 Condition (jakarta.nosql.query.Condition)6 DelQuery (jakarta.nosql.query.DelQuery)6 GetQuery (jakarta.nosql.query.GetQuery)6 Where (jakarta.nosql.query.Where)6 FunctionQueryValue (jakarta.nosql.query.FunctionQueryValue)5 JSONQueryValue (jakarta.nosql.query.JSONQueryValue)5 Params (jakarta.nosql.Params)3 QueryException (jakarta.nosql.QueryException)3 DeleteQuery (jakarta.nosql.query.DeleteQuery)3 Function (jakarta.nosql.query.Function)3 SelectQuery (jakarta.nosql.query.SelectQuery)3 ValueType (jakarta.nosql.query.ValueType)3