DATAJPA-342 - Corrected generated count projection from string queries.
The variable put into the count(…) clause of the generated query is now the original value except we find a DTO project or a count projection in the first place.
This commit is contained in:
@@ -203,6 +203,16 @@ public class QueryUtilsUnitTests {
|
||||
assertThat(applySorting(query, sort, "p"), endsWith("order by p.lastname asc, lower(p.firstname) asc"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-342
|
||||
*/
|
||||
@Test
|
||||
public void usesReturnedVariableInCOuntProjectionIfSet() {
|
||||
|
||||
assertCountQuery("select distinct m.genre from Media m where m.user = ?1 order by m.genre asc",
|
||||
"select count(distinct m.genre) from Media m where m.user = ?1 order by m.genre asc");
|
||||
}
|
||||
|
||||
private void assertCountQuery(String originalQuery, String countQuery) {
|
||||
assertThat(createCountQueryFor(originalQuery), is(countQuery));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user