Skip to content

Commit ee04012

Browse files
committed
Use queryScanConsistency on reactive deleteAll().
It was present on non-Reactive, but missing from reactive. Closes #1096. Original pull request: #1108. Co-authored-by: mikereiche <[email protected]>
1 parent 2554e61 commit ee04012

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/main/java/org/springframework/data/couchbase/repository/support/SimpleReactiveCouchbaseRepository.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.data.couchbase.repository.support;
1818

19-
import static org.springframework.data.couchbase.repository.support.Util.*;
19+
import static org.springframework.data.couchbase.repository.support.Util.hasNonZeroVersionProperty;
2020

2121
import reactor.core.publisher.Flux;
2222
import reactor.core.publisher.Mono;
@@ -26,7 +26,6 @@
2626
import java.util.stream.Collectors;
2727

2828
import org.reactivestreams.Publisher;
29-
3029
import org.springframework.data.couchbase.core.CouchbaseOperations;
3130
import org.springframework.data.couchbase.core.ReactiveCouchbaseOperations;
3231
import org.springframework.data.couchbase.core.query.Query;
@@ -189,7 +188,8 @@ public Mono<Long> count() {
189188

190189
@Override
191190
public Mono<Void> deleteAll() {
192-
return operations.removeByQuery(entityInformation.getJavaType()).all().then();
191+
return operations.removeByQuery(entityInformation.getJavaType()).withConsistency(buildQueryScanConsistency()).all()
192+
.then();
193193
}
194194

195195
/**

src/test/java/org/springframework/data/couchbase/domain/ReactiveAirportRepository.java

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public interface ReactiveAirportRepository extends ReactiveSortingRepository<Air
4545
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
4646
Flux<Airport> findAll();
4747

48+
@Override
49+
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
50+
Mono<Void> deleteAll();
51+
4852
@Override
4953
Mono<Airport> save(Airport a);
5054

src/test/java/org/springframework/data/couchbase/repository/ReactiveCouchbaseRepositoryQueryIntegrationTests.java

+19
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@ void deleteAllById() {
195195
}
196196
}
197197

198+
@Test
199+
void deleteAll() {
200+
201+
Airport vienna = new Airport("airports::vie", "vie", "LOWW");
202+
Airport frankfurt = new Airport("airports::fra", "fra", "EDDF");
203+
Airport losAngeles = new Airport("airports::lax", "lax", "KLAX");
204+
205+
try {
206+
airportRepository.saveAll(asList(vienna, frankfurt, losAngeles)).as(StepVerifier::create)
207+
.expectNext(vienna, frankfurt, losAngeles).verifyComplete();
208+
209+
airportRepository.deleteAll().as(StepVerifier::create).verifyComplete();
210+
211+
airportRepository.findAll().as(StepVerifier::create).verifyComplete();
212+
} finally {
213+
airportRepository.deleteAll().block();
214+
}
215+
}
216+
198217
@Configuration
199218
@EnableReactiveCouchbaseRepositories("org.springframework.data.couchbase")
200219
static class Config extends AbstractCouchbaseConfiguration {

0 commit comments

Comments
 (0)