From f746d5f496c21abf8d584be159b43e6cea1da62f Mon Sep 17 00:00:00 2001 From: Michael Reiche <48999328+mikereiche@users.noreply.github.com> Date: Tue, 19 Apr 2022 16:57:52 -0700 Subject: [PATCH] Count not requiring specific property name. (#1414) Closes #1413. --- .../couchbase/core/ReactiveFindByQueryOperationSupport.java | 5 ++--- .../repository/CouchbaseRepositoryQueryIntegrationTests.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveFindByQueryOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveFindByQueryOperationSupport.java index 0ff613dc..b516a751 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveFindByQueryOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveFindByQueryOperationSupport.java @@ -223,9 +223,8 @@ public class ReactiveFindByQueryOperationSupport implements ReactiveFindByQueryO } else { return throwable; } - }).flatMapMany(ReactiveQueryResult::rowsAsObject).map(row -> { - return row.getLong(TemplateUtils.SELECT_COUNT); - }).next(); + }).flatMapMany(ReactiveQueryResult::rowsAsObject).map(row -> row.getLong(row.getNames().iterator().next())) + .next(); }); } diff --git a/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java index ba6becf5..5d42f221 100644 --- a/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java @@ -431,7 +431,7 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr @Test void badCount() { - assertThrows(CouchbaseQueryExecutionException.class, () -> airportRepository.countBad()); + assertThrows(NullPointerException.class, () -> airportRepository.countBad()); } @Test