DATAMONGO-765 - Polishing.
Reformat code. Update ticket references. Original pull request: #806.
This commit is contained in:
@@ -167,12 +167,15 @@ public class GridFsTemplate extends GridFsOperationsSupport implements GridFsOpe
|
||||
Document sortObject = getMappedQuery(query.getSortObject());
|
||||
|
||||
GridFSFindIterable iterable = getGridFs().find(queryObject).sort(sortObject);
|
||||
|
||||
if (query.getSkip() > 0) {
|
||||
iterable = iterable.skip(Math.toIntExact(query.getSkip()));
|
||||
}
|
||||
|
||||
if (query.getLimit() > 0) {
|
||||
iterable = iterable.limit(query.getLimit());
|
||||
}
|
||||
|
||||
return iterable;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,12 +262,15 @@ public class ReactiveGridFsTemplate extends GridFsOperationsSupport implements R
|
||||
Document sortObject = getMappedQuery(query.getSortObject());
|
||||
|
||||
GridFSFindPublisher publisherToUse = getGridFs().find(queryObject).sort(sortObject);
|
||||
|
||||
if (query.getLimit() > 0) {
|
||||
publisherToUse = publisherToUse.limit(query.getLimit());
|
||||
}
|
||||
|
||||
if (query.getSkip() > 0) {
|
||||
publisherToUse = publisherToUse.skip(Math.toIntExact(query.getSkip()));
|
||||
}
|
||||
|
||||
Integer cursorBatchSize = query.getMeta().getCursorBatchSize();
|
||||
if (cursorBatchSize != null) {
|
||||
publisherToUse = publisherToUse.batchSize(cursorBatchSize);
|
||||
|
||||
@@ -293,10 +293,10 @@ public class GridFsTemplateIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2411
|
||||
@Test // DATAMONGO-765
|
||||
public void considersSkipLimitWhenQueryingFiles() {
|
||||
Stream.of( //
|
||||
"a", "aa", "aaa", //
|
||||
|
||||
Stream.of("a", "aa", "aaa", //
|
||||
"b", "bb", "bb", //
|
||||
"c", "cc", "ccc", //
|
||||
"d", "dd", "ddd") //
|
||||
|
||||
@@ -289,17 +289,19 @@ public class ReactiveGridFsTemplateTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2411
|
||||
@Test // DATAMONGO-765
|
||||
public void considersSkipLimitWhenQueryingFiles() {
|
||||
|
||||
DataBufferFactory bufferFactory = new DefaultDataBufferFactory();
|
||||
DataBuffer buffer = bufferFactory.allocateBuffer(0);
|
||||
Flux.just( //
|
||||
"a", "aa", "aaa", //
|
||||
Flux.just("a", "aa", "aaa", //
|
||||
"b", "bb", "bbb", //
|
||||
"c", "cc", "ccc", //
|
||||
"d", "dd", "ddd") //
|
||||
.flatMap(fileName -> operations.store(Mono.just(buffer), fileName)) //
|
||||
.blockLast();
|
||||
.as(StepVerifier::create) //
|
||||
.expectNextCount(12) //
|
||||
.verifyComplete();
|
||||
|
||||
PageRequest pageRequest = PageRequest.of(2, 3, Sort.Direction.ASC, "filename");
|
||||
operations.find(new Query().with(pageRequest)) //
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
== What's New in Spring Data MongoDB 2.3
|
||||
|
||||
* Support for <<mongo-template.aggregation-update,aggregation pipelines in update operations>>.
|
||||
* Apply pagination when using GridFS `find(Query)`.
|
||||
|
||||
[[new-features.2-2-0]]
|
||||
== What's New in Spring Data MongoDB 2.2
|
||||
|
||||
* Compatibility with MongoDB 4.2 deprecating `eval`, `group` and `geoNear` Template API methods.
|
||||
* Extended SpEL aggregation support for MongoDB 3.4 and MongoDB 4.0 operators (see <<mongo.aggregation.projection.expressions>>).
|
||||
* <<mongodb.reactive.repositories.queries.type-safe,Querydsl support for reactive repositories>> via `ReactiveQuerydslPredicateExecutor`.
|
||||
|
||||
Reference in New Issue
Block a user