Skip to content

Commit 91c39e2

Browse files
committed
DATAMONGO-2630 - Add support for suspend repository query methods returning List<T>.
1 parent 965a34e commit 91c39e2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/ReactiveMongoQueryMethod.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ public ReactiveMongoQueryMethod(Method method, RepositoryMetadata metadata, Proj
9494
}
9595

9696
this.method = method;
97-
this.isCollectionQuery = Lazy.of(() -> !(isPageQuery() || isSliceQuery())
98-
&& ReactiveWrappers.isMultiValueType(metadata.getReturnType(method).getType()));
97+
this.isCollectionQuery = Lazy.of(() -> (!(isPageQuery() || isSliceQuery())
98+
&& ReactiveWrappers.isMultiValueType(metadata.getReturnType(method).getType()) || super.isCollectionQuery()));
9999
}
100100

101101
/*

spring-data-mongodb/src/test/kotlin/org/springframework/data/mongodb/repository/query/ReactiveMongoQueryMethodCoroutineUnitTests.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class ReactiveMongoQueryMethodCoroutineUnitTests {
3939
suspend fun findSuspendAllByName(): Flow<Person>
4040

4141
fun findAllByName(): Flow<Person>
42+
43+
suspend fun findSuspendByName(): List<Person>
4244
}
4345

4446
@Test // DATAMONGO-2562
@@ -58,4 +60,13 @@ class ReactiveMongoQueryMethodCoroutineUnitTests {
5860

5961
assertThat(queryMethod.isCollectionQuery).isTrue()
6062
}
63+
64+
@Test // DATAMONGO-2630
65+
internal fun `should consider suspended methods returning List as collection queries`() {
66+
67+
val method = PersonRepository::class.java.getMethod("findSuspendByName", Continuation::class.java)
68+
val queryMethod = ReactiveMongoQueryMethod(method, DefaultRepositoryMetadata(PersonRepository::class.java), projectionFactory, MongoMappingContext())
69+
70+
assertThat(queryMethod.isCollectionQuery).isTrue()
71+
}
6172
}

0 commit comments

Comments
 (0)