Search in sources :

Example 21 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldPrependAllToSet.

// DATACASS-770
@Test
void shouldPrependAllToSet() {
    Update update = updateMapper.getMappedObject(Update.empty().addTo("set").prependAll(currencyUSD, currencyEUR), persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("set_col = {'US Dollar','Euro'} + set_col");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Example 22 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldCreateSetAtIndexUpdate.

// DATACASS-343
@Test
void shouldCreateSetAtIndexUpdate() {
    Update update = updateMapper.getMappedObject(Update.empty().set("list").atIndex(10).to(currencyEUR), persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("list[10] = 'Euro'");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Example 23 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldCreateSimpleUpdate.

// DATACASS-343
@Test
void shouldCreateSimpleUpdate() {
    Update update = updateMapper.getMappedObject(Update.empty().set("firstName", "foo"), persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("first_name = 'foo'");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Example 24 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldAppendAllToSet.

// DATACASS-770
@Test
void shouldAppendAllToSet() {
    Update update = updateMapper.getMappedObject(Update.empty().addTo("set").appendAll(currencyUSD, currencyEUR), persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("set_col = set_col + {'US Dollar','Euro'}");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Example 25 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldMapTuple.

// DATACASS-523
@Test
void shouldMapTuple() {
    Update update = this.updateMapper.getMappedObject(Update.empty().set("tuple", new MappedTuple("foo")), this.persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("tuple = ('foo')");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Aggregations

Update (org.springframework.data.cassandra.core.query.Update)51 Test (org.junit.jupiter.api.Test)49 Query (org.springframework.data.cassandra.core.query.Query)15 WriteOptions (org.springframework.data.cassandra.core.cql.WriteOptions)7 Filter (org.springframework.data.cassandra.core.query.Filter)5 LinkedHashMap (java.util.LinkedHashMap)3 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)2 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)2 ClusteringOrder (com.datastax.oss.driver.api.core.metadata.schema.ClusteringOrder)2 BindMarker (com.datastax.oss.driver.api.querybuilder.BindMarker)2 QueryBuilder (com.datastax.oss.driver.api.querybuilder.QueryBuilder)2 Condition (com.datastax.oss.driver.api.querybuilder.condition.Condition)2 ConditionBuilder (com.datastax.oss.driver.api.querybuilder.condition.ConditionBuilder)2 Delete (com.datastax.oss.driver.api.querybuilder.delete.Delete)2 DeleteSelection (com.datastax.oss.driver.api.querybuilder.delete.DeleteSelection)2 Insert (com.datastax.oss.driver.api.querybuilder.insert.Insert)2 RegularInsert (com.datastax.oss.driver.api.querybuilder.insert.RegularInsert)2 ColumnRelationBuilder (com.datastax.oss.driver.api.querybuilder.relation.ColumnRelationBuilder)2 Relation (com.datastax.oss.driver.api.querybuilder.relation.Relation)2 Select (com.datastax.oss.driver.api.querybuilder.select.Select)2