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 @@ -259,7 +259,7 @@ public String toString() {
259
259
*/
260
260
private Sort withDirection (Direction direction ) {
261
261
262
- return Sort .by (stream ().map (it -> new Order ( direction , it .getProperty () )).collect (Collectors .toList ()));
262
+ return Sort .by (stream ().map (it -> it .with ( direction )).collect (Collectors .toList ()));
263
263
}
264
264
265
265
/**
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