DATAJPA-148 - Remove qualification of sort reference for functions.
When applying Sort instances we now check for the presence of a ( which indicates a function to be executed.
This commit is contained in:
@@ -212,7 +212,7 @@ public abstract class QueryUtils {
|
||||
private static String getOrderClause(Set<String> joinAliases, String alias, Order order) {
|
||||
|
||||
String property = order.getProperty();
|
||||
boolean qualifyReference = true;
|
||||
boolean qualifyReference = !property.contains("("); // ( indicates a function
|
||||
|
||||
for (String joinAlias : joinAliases) {
|
||||
if (property.startsWith(joinAlias)) {
|
||||
|
||||
@@ -223,6 +223,16 @@ public class QueryUtilsUnitTests {
|
||||
"select count(o) from Foo o where cb.id in (select b from Bar b)");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-148
|
||||
*/
|
||||
@Test
|
||||
public void doesNotPrefixSortsIfFunction() {
|
||||
|
||||
Sort sort = new Sort("sum(foo)");
|
||||
assertThat(applySorting("select p from Person p", sort, "p"), endsWith("order by sum(foo) asc"));
|
||||
}
|
||||
|
||||
private void assertCountQuery(String originalQuery, String countQuery) {
|
||||
assertThat(createCountQueryFor(originalQuery), is(countQuery));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user