File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 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) {
286286 public Query with (Pageable pageable ) {
287287
288288 if (pageable .isUnpaged ()) {
289+ if (pageable .getSort ().isSorted ()) {
290+ return with (pageable .getSort ());
291+ }
289292 return this ;
290293 }
291294
Original file line number Diff line number Diff line change 2323import org .junit .jupiter .api .Test ;
2424import org .springframework .aop .framework .ProxyFactory ;
2525import org .springframework .data .domain .Limit ;
26+ import org .springframework .data .domain .Pageable ;
2627import org .springframework .data .domain .Sort ;
2728import org .springframework .data .domain .Sort .Direction ;
2829import org .springframework .data .domain .Sort .Order ;
@@ -366,6 +367,15 @@ void queryOfShouldWorkOnProxiedObjects() {
366367 compareQueries (target , source );
367368 }
368369
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+
369379 private void compareQueries (Query actual , Query expected ) {
370380
371381 assertThat (actual .getCollation ()).isEqualTo (expected .getCollation ());
You can’t perform that action at this time.
0 commit comments