DATAMONGO-2630 - Add support for suspend repository query methods returning List<T>.

This commit is contained in:
Mark Paluch
2020-09-22 14:53:19 +02:00
parent 965a34efd3
commit 91c39e2825
2 changed files with 13 additions and 2 deletions

View File

@@ -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()));
}
/*

View File

@@ -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()
}
}