Automatically set readonly query option for read only queries (#1730)
Closes #1724
This commit is contained in:
@@ -698,7 +698,7 @@ class CouchbaseTemplateQueryCollectionIntegrationTests extends CollectionAwareIn
|
||||
@Test
|
||||
public void findByQueryOptions() { // 4
|
||||
QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofNanos(10));
|
||||
assertThrows(AmbiguousTimeoutException.class, () -> couchbaseTemplate.findByQuery(Airport.class)
|
||||
assertThrows(UnambiguousTimeoutException.class, () -> couchbaseTemplate.findByQuery(Airport.class)
|
||||
.withConsistency(REQUEST_PLUS).inScope(otherScope).inCollection(otherCollection).withOptions(options).all());
|
||||
}
|
||||
|
||||
|
||||
@@ -689,7 +689,7 @@ class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests extends Collectio
|
||||
@Test
|
||||
public void findByQueryOptions() { // 4
|
||||
QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofNanos(10));
|
||||
assertThrows(AmbiguousTimeoutException.class,
|
||||
assertThrows(UnambiguousTimeoutException.class,
|
||||
() -> template.findByQuery(Airport.class).withConsistency(REQUEST_PLUS).inScope(otherScope)
|
||||
.inCollection(otherCollection).withOptions(options).all().collectList().block());
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.springframework.data.couchbase.config.BeanNames.COUCHBASE_TEMPLATE;
|
||||
|
||||
import com.couchbase.client.core.error.UnambiguousTimeoutException;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
@@ -644,7 +645,7 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
|
||||
try {
|
||||
Airport saved = airportRepository.save(vie);
|
||||
// Duration of 1 nano-second will cause timeout
|
||||
assertThrows(AmbiguousTimeoutException.class,
|
||||
assertThrows(UnambiguousTimeoutException.class,
|
||||
() -> airportRepository.withOptions(queryOptions().timeout(Duration.ofNanos(1))).iata(vie.getIata()));
|
||||
|
||||
Airport airport3 = airportRepository
|
||||
|
||||
Reference in New Issue
Block a user