use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParser method query.
Stream<ColumnEntity> query(String query, ColumnFamilyManager manager, ColumnObserverParser observer) {
ColumnDeleteQuery columnDeleteQuery = cache.get(query, observer);
manager.delete(columnDeleteQuery);
return Stream.empty();
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParser method getQuery.
private ColumnDeleteQuery getQuery(Params params, ColumnObserverParser observer, DeleteQuery deleteQuery) {
String columnFamily = observer.fireEntity(deleteQuery.getEntity());
List<String> columns = deleteQuery.getFields().stream().map(f -> observer.fireField(columnFamily, f)).collect(Collectors.toList());
ColumnCondition condition = null;
if (deleteQuery.getWhere().isPresent()) {
condition = deleteQuery.getWhere().map(c -> Conditions.getCondition(c, params, observer, columnFamily)).get();
}
return new DefaultColumnDeleteQuery(columnFamily, condition, columns);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParser method getQuery.
private ColumnDeleteQuery getQuery(String query, ColumnObserverParser observer) {
DeleteQuery deleteQuery = deleteQueryProvider.apply(query);
String columnFamily = observer.fireEntity(deleteQuery.getEntity());
List<String> columns = deleteQuery.getFields().stream().map(f -> observer.fireField(columnFamily, f)).collect(Collectors.toList());
ColumnCondition condition = null;
Params params = Params.newParams();
if (deleteQuery.getWhere().isPresent()) {
condition = deleteQuery.getWhere().map(c -> Conditions.getCondition(c, params, observer, columnFamily)).get();
}
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
return new DefaultColumnDeleteQuery(columnFamily, condition, columns);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultColumnMapperDeleteBuilderTest method shouldExecuteDeleteFrom.
@Test
public void shouldExecuteDeleteFrom() {
ColumnTemplate template = Mockito.mock(ColumnTemplate.class);
ArgumentCaptor<ColumnDeleteQuery> queryCaptor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
mapperBuilder.deleteFrom(Person.class).delete(template);
Mockito.verify(template).delete(queryCaptor.capture());
ColumnDeleteQuery query = queryCaptor.getValue();
ColumnDeleteQuery queryExpected = delete().from("Person").build();
assertEquals(queryExpected, query);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultColumnMapperDeleteBuilderTest method shouldSelectWhereNameOr.
@Test
public void shouldSelectWhereNameOr() {
ColumnDeleteQuery query = mapperBuilder.deleteFrom(Person.class).where("id").between(10, 20).or("name").eq("Ada").build();
ColumnDeleteQuery queryExpected = delete().from("Person").where("_id").between(10L, 20L).or("name").eq("Ada").build();
assertEquals(queryExpected, query);
}
Aggregations