Skip to content

Commit 1281c7c

Browse files
committed
DATAJPA-1198 - Polishing.
Compare types using equals(…). Reformat code. Original pull request: #428.
1 parent 3443711 commit 1281c7c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ private Expression<?> buildOrderPropertyPathFrom(Order order) {
236236

237237
while (path != null) {
238238

239-
sortPropertyExpression = !path.hasNext() && order.isIgnoreCase() && String.class == path.getType() //
239+
sortPropertyExpression = !path.hasNext() && order.isIgnoreCase() && String.class.equals(path.getType()) //
240240
? Expressions.stringPath((Path<?>) sortPropertyExpression, path.getSegment()).lower() //
241241
: Expressions.path(path.getType(), (Path<?>) sortPropertyExpression, path.getSegment());
242242

src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20+
import java.util.stream.Stream;
21+
2022
import javax.persistence.EntityManager;
2123
import javax.persistence.PersistenceContext;
2224

2325
import org.junit.Before;
2426
import org.junit.Test;
2527
import org.junit.runner.RunWith;
28+
2629
import org.springframework.data.domain.Sort;
2730
import org.springframework.data.jpa.domain.sample.User;
2831
import org.springframework.test.context.ContextConfiguration;
@@ -32,8 +35,6 @@
3235
import com.querydsl.core.types.dsl.PathBuilder;
3336
import com.querydsl.jpa.JPQLQuery;
3437

35-
import java.util.stream.Stream;
36-
3738
/**
3839
* Integration tests for {@link Querydsl}.
3940
*
@@ -71,8 +72,9 @@ public void defaultOrderingShouldNotGenerateAnNullOrderingHint() {
7172
.doesNotContain("nulls last");
7273
}
7374

74-
@Test // DATAJPA-1198; DATAJPA-1779
75+
@Test // DATAJPA-1779
7576
public void orderWithIgnoreCaseAddLowerOnlyStringType() {
77+
7678
// firstname (String); id (Integer); dateOfBirth (Date)
7779
Sort.Order[] orders = Stream.of("firstname", "id", "dateOfBirth").map(name -> Sort.Order.asc(name).ignoreCase()).toArray(Sort.Order[]::new);
7880
JPQLQuery<User> result = querydsl.applySorting(Sort.by(orders), userQuery);

0 commit comments

Comments
 (0)