use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.
the class StatementFactoryUnitTests method shouldRemoveFromList.
// DATACASS-343
@Test
void shouldRemoveFromList() {
Update update = Update.empty().remove("list", "Euro");
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> updateStatementBuilder = statementFactory.update(Query.empty(), update, personEntity);
assertThat(updateStatementBuilder.build(ParameterHandling.INLINE).getQuery()).isEqualTo("UPDATE person SET list=list-['Euro']");
}
use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.
the class StatementFactoryUnitTests method shouldCreateSetUpdateFromObjectWithTtl.
// DATACASS-656
@Test
void shouldCreateSetUpdateFromObjectWithTtl() {
WriteOptions options = WriteOptions.builder().ttl(Duration.ofMinutes(1)).build();
Person person = new Person();
person.id = "foo";
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory.update(person, options);
assertThat(update.build(ParameterHandling.INLINE).getQuery()).startsWith("UPDATE person USING TTL 60 SET");
}
use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.
the class CassandraTemplateUnitTests method updateShouldApplyUpdateQueryWitLwt.
// DATACASS-575
@Test
void updateShouldApplyUpdateQueryWitLwt() {
Filter ifCondition = Filter.from(where("firstname").is("Walter"), where("lastname").is("White"));
Query query = Query.query(where("id").is("heisenberg")).queryOptions(UpdateOptions.builder().ifCondition(ifCondition).build());
Update update = Update.update("firstname", "Walter");
template.update(query, update, User.class);
verify(session).execute(statementCaptor.capture());
assertThat(render(statementCaptor.getValue())).isEqualTo("UPDATE users SET firstname='Walter' WHERE id='heisenberg' IF firstname='Walter' AND lastname='White'");
}
use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.
the class UpdateMapperUnitTests method shouldPrependToSet.
// DATACASS-770
@Test
void shouldPrependToSet() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("set").prepend(currencyEUR), persistentEntity);
assertThat(update.getUpdateOperations()).hasSize(1);
assertThat(update).hasToString("set_col = {'Euro'} + set_col");
}
use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.
the class UpdateMapperUnitTests method shouldAddToMap.
// DATACASS-343
@Test
void shouldAddToMap() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("map").entry("foo", currencyEUR), persistentEntity);
assertThat(update.getUpdateOperations()).hasSize(1);
assertThat(update).hasToString("map = map + {'foo':'Euro'}");
}
Aggregations