File tree 2 files changed +14
-2
lines changed
main/java/org/springframework/data/domain
test/java/org/springframework/data/domain
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ public String toString() {
277
277
*/
278
278
private Sort withDirection (Direction direction ) {
279
279
280
- return Sort .by (stream ().map (it -> new Order ( direction , it .getProperty () )).collect (Collectors .toList ()));
280
+ return Sort .by (stream ().map (it -> it .with ( direction )).collect (Collectors .toList ()));
281
281
}
282
282
283
283
/**
Original file line number Diff line number Diff line change @@ -104,9 +104,12 @@ void handlesAdditionalNullSort() {
104
104
assertThat (sort ).containsExactly (Order .by ("foo" ));
105
105
}
106
106
107
- @ Test // DATACMNS-281, DATACMNS-1021
107
+ @ Test // DATACMNS-281, DATACMNS-1021, GH-2585
108
108
void configuresIgnoreCaseForOrder () {
109
+
109
110
assertThat (Order .asc ("foo" ).ignoreCase ().isIgnoreCase ()).isTrue ();
111
+ assertThat (Sort .by (Order .by ("foo" ).ignoreCase ()).descending ().iterator ().next ().isIgnoreCase ()).isTrue ();
112
+ assertThat (Sort .by (Order .by ("foo" ).ignoreCase ()).ascending ().iterator ().next ().isIgnoreCase ()).isTrue ();
110
113
}
111
114
112
115
@ Test // DATACMNS-281, DATACMNS-1021
@@ -154,6 +157,15 @@ void orderWithDefaultNullHandlingHint() {
154
157
assertThat (Order .by ("foo" ).getNullHandling ()).isEqualTo (NATIVE );
155
158
}
156
159
160
+ @ Test // GH-2585
161
+ void retainsNullHandlingAfterChangingDirection () {
162
+
163
+ assertThat (Sort .by (Order .by ("foo" ).with (NULLS_FIRST )).ascending ().iterator ().next ().getNullHandling ())
164
+ .isEqualTo (NULLS_FIRST );
165
+ assertThat (Sort .by (Order .by ("foo" ).with (NULLS_FIRST )).descending ().iterator ().next ().getNullHandling ())
166
+ .isEqualTo (NULLS_FIRST );
167
+ }
168
+
157
169
@ Test // DATACMNS-908
158
170
void createsNewOrderForDifferentProperty () {
159
171
You can’t perform that action at this time.
0 commit comments