use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class SelectQueryProviderTest method shouldReturnParserQuery7.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God limit 12" })
public void shouldReturnParserQuery7(String query) {
SelectQuery selectQuery = selectQueryProvider.apply(query);
assertEquals("God", selectQuery.getEntity());
assertTrue(selectQuery.getFields().isEmpty());
assertTrue(selectQuery.getOrderBy().isEmpty());
assertEquals(12, selectQuery.getLimit());
assertEquals(0, selectQuery.getSkip());
assertFalse(selectQuery.getWhere().isPresent());
}
use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class SelectQueryProviderTest method shouldReturnParserQuery12.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where stamina <= 10.23" })
public void shouldReturnParserQuery12(String query) {
SelectQuery selectQuery = checkSelectFromStart(query);
assertTrue(selectQuery.getWhere().isPresent());
Where where = selectQuery.getWhere().get();
Condition condition = where.getCondition();
QueryValue<?> value = condition.getValue();
Assertions.assertEquals(Operator.LESSER_EQUALS_THAN, condition.getOperator());
assertEquals("stamina", condition.getName());
assertTrue(value instanceof NumberQueryValue);
assertEquals(10.23, value.get());
}
use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class BaseDocumentRepository method getQuery.
protected DocumentQuery getQuery(Method method, Object[] args) {
SelectMethodProvider methodProvider = SelectMethodProvider.get();
SelectQuery selectQuery = methodProvider.apply(method, getClassMapping().getName());
SelectQueryConverter converter = ServiceLoaderProvider.get(SelectQueryConverter.class);
DocumentQueryParams queryParams = converter.apply(selectQuery, getParser());
DocumentQuery query = queryParams.getQuery();
Params params = queryParams.getParams();
getParamsBinder().bind(params, args, method);
return getQuerySorts(args, query);
}
use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class SelectQueryConverter method apply.
@Override
public Stream<Vertex> apply(GraphQueryMethod graphQuery, Object[] params) {
SelectMethodProvider selectMethodFactory = SelectMethodProvider.get();
SelectQuery query = selectMethodFactory.apply(graphQuery.getMethod(), graphQuery.getEntityName());
ClassMapping mapping = graphQuery.getMapping();
GraphTraversal<Vertex, Vertex> traversal = getGraphTraversal(graphQuery, query::getWhere, mapping);
query.getOrderBy().forEach(getSort(traversal, mapping));
setSort(params, traversal);
setPagination(params, traversal, query);
traversal.hasLabel(mapping.getName());
return traversal.toStream();
}
use of jakarta.nosql.query.SelectQuery in project jnosql-diana by eclipse.
the class SelectQueryProviderTest method shouldReturnParserQuery23.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where name like \"Ada\"" })
public void shouldReturnParserQuery23(String query) {
SelectQuery selectQuery = checkSelectFromStart(query);
assertTrue(selectQuery.getWhere().isPresent());
Where where = selectQuery.getWhere().get();
Condition condition = where.getCondition();
QueryValue<?> value = condition.getValue();
Assertions.assertEquals(Operator.LIKE, condition.getOperator());
assertEquals("name", condition.getName());
assertTrue(value instanceof StringQueryValue);
assertEquals("Ada", StringQueryValue.class.cast(value).get());
}
Aggregations