use of jakarta.nosql.query.DelQuery in project jnosql-diana by eclipse.
the class RemoveProviderTest method shouldReturnParserQuery5.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "del {1,12}" })
public void shouldReturnParserQuery5(String query) {
DelQuery delQuery = provider.apply(query);
List<QueryValue<?>> keys = delQuery.getKeys();
assertEquals(1, keys.size());
QueryValue<?> key = keys.get(0);
assertTrue(key instanceof ArrayQueryValue);
QueryValue<?>[] values = ArrayQueryValue.class.cast(key).get();
MatcherAssert.assertThat(Arrays.stream(values).map(QueryValue::get).collect(Collectors.toList()), Matchers.contains(1L, 12L));
}
use of jakarta.nosql.query.DelQuery in project jnosql-diana by eclipse.
the class DelQueryParser method prepare.
public KeyValuePreparedStatement prepare(String query, BucketManager manager) {
DelQuery delQuery = provider.apply(query);
Params params = Params.newParams();
List<Value> values = delQuery.getKeys().stream().map(k -> Values.getValue(k, params)).collect(toList());
return DefaultKeyValuePreparedStatement.del(values, manager, params, query);
}
use of jakarta.nosql.query.DelQuery in project jnosql-diana by eclipse.
the class DelQueryParser method query.
Stream<Value> query(String query, BucketManager manager) {
DelQuery delQuery = provider.apply(query);
Params params = Params.newParams();
List<Value> values = delQuery.getKeys().stream().map(k -> Values.getValue(k, params)).collect(toList());
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
List<Object> keys = values.stream().map(Value::get).collect(toList());
manager.delete(keys);
return Stream.empty();
}
Aggregations