DATAJPA-296 - Fixed application of ignore case flag on string queries.

The ignore-case flag held in a Sort.Order is now also applied when manually defining queries.
This commit is contained in:
Oliver Gierke
2013-04-18 11:20:14 +02:00
parent 0bf2cb391e
commit 4c65ad1df6
2 changed files with 29 additions and 2 deletions

View File

@@ -179,6 +179,30 @@ public class QueryUtilsUnitTests {
assertThat(applySorting(query, new Sort("firstname"), "p"), endsWith("order by p.lastname asc, p.firstname asc"));
}
/**
* @see DATAJPA-296
*/
@Test
public void appliesIgnoreCaseOrderingCorrectly() {
Sort sort = new Sort(new Sort.Order("firstname").ignoreCase());
String query = "select p from Person p";
assertThat(applySorting(query, sort, "p"), endsWith("order by lower(p.firstname) asc"));
}
/**
* @see DATAJPA-296
*/
@Test
public void appendsIgnoreCaseOrderingCorrectly() {
Sort sort = new Sort(new Sort.Order("firstname").ignoreCase());
String query = "select p from Person p order by p.lastname asc";
assertThat(applySorting(query, sort, "p"), endsWith("order by p.lastname asc, lower(p.firstname) asc"));
}
private void assertCountQuery(String originalQuery, String countQuery) {
assertThat(createCountQueryFor(originalQuery), is(countQuery));
}