DATAMONGO-2630 - Add support for suspend repository query methods returning List<T>.
This commit is contained in:
@@ -94,8 +94,8 @@ public class ReactiveMongoQueryMethod extends MongoQueryMethod {
|
||||
}
|
||||
|
||||
this.method = method;
|
||||
this.isCollectionQuery = Lazy.of(() -> !(isPageQuery() || isSliceQuery())
|
||||
&& ReactiveWrappers.isMultiValueType(metadata.getReturnType(method).getType()));
|
||||
this.isCollectionQuery = Lazy.of(() -> (!(isPageQuery() || isSliceQuery())
|
||||
&& ReactiveWrappers.isMultiValueType(metadata.getReturnType(method).getType()) || super.isCollectionQuery()));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -39,6 +39,8 @@ class ReactiveMongoQueryMethodCoroutineUnitTests {
|
||||
suspend fun findSuspendAllByName(): Flow<Person>
|
||||
|
||||
fun findAllByName(): Flow<Person>
|
||||
|
||||
suspend fun findSuspendByName(): List<Person>
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2562
|
||||
@@ -58,4 +60,13 @@ class ReactiveMongoQueryMethodCoroutineUnitTests {
|
||||
|
||||
assertThat(queryMethod.isCollectionQuery).isTrue()
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2630
|
||||
internal fun `should consider suspended methods returning List as collection queries`() {
|
||||
|
||||
val method = PersonRepository::class.java.getMethod("findSuspendByName", Continuation::class.java)
|
||||
val queryMethod = ReactiveMongoQueryMethod(method, DefaultRepositoryMetadata(PersonRepository::class.java), projectionFactory, MongoMappingContext())
|
||||
|
||||
assertThat(queryMethod.isCollectionQuery).isTrue()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user