DATAMONGO-765 - Polishing.

Reformat code. Update ticket references.

Original pull request: #806.
This commit is contained in:
Mark Paluch
2019-11-26 15:20:57 +01:00
parent 1d98b77f3d
commit dbf43941be
5 changed files with 17 additions and 7 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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") //

View File

@@ -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)) //

View File

@@ -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`.