File tree 2 files changed +13
-0
lines changed
main/java/org/springframework/data/mongodb/core/query
test/java/org/springframework/data/mongodb/core/query
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,9 @@ public Query withHint(Document hint) {
286
286
public Query with (Pageable pageable ) {
287
287
288
288
if (pageable .isUnpaged ()) {
289
+ if (pageable .getSort ().isSorted ()) {
290
+ return with (pageable .getSort ());
291
+ }
289
292
return this ;
290
293
}
291
294
Original file line number Diff line number Diff line change 23
23
import org .junit .jupiter .api .Test ;
24
24
import org .springframework .aop .framework .ProxyFactory ;
25
25
import org .springframework .data .domain .Limit ;
26
+ import org .springframework .data .domain .Pageable ;
26
27
import org .springframework .data .domain .Sort ;
27
28
import org .springframework .data .domain .Sort .Direction ;
28
29
import org .springframework .data .domain .Sort .Order ;
@@ -366,6 +367,15 @@ void queryOfShouldWorkOnProxiedObjects() {
366
367
compareQueries (target , source );
367
368
}
368
369
370
+ @ Test // GH-4771
371
+ void appliesSortOfUnpagedPageable () {
372
+
373
+ Query query = new Query ();
374
+ query .with (Pageable .unpaged (Sort .by ("sortMe" )));
375
+
376
+ assertThat (query .isSorted ()).isTrue ();
377
+ }
378
+
369
379
private void compareQueries (Query actual , Query expected ) {
370
380
371
381
assertThat (actual .getCollation ()).isEqualTo (expected .getCollation ());
You can’t perform that action at this time.
0 commit comments