-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Introduce support for sorting by aliased projections #2865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
} | ||
|
||
private boolean orderParameterIsAFunction(Sort.Order order) { | ||
return order.getProperty().contains("("); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this even remotely possible? While properties are string, do we rewrite the sort to contain a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check for functions in Sort
is something we already look for in QueryUtils
.
In fact, we have existing test cases like this:
@Test // DATAJPA-148
void doesNotPrefixSortsIfFunction() {
StringQuery query = new StringQuery("select p from Person p", true);
Sort sort = Sort.by("sum(foo)");
QueryEnhancer enhancer = getEnhancer(query);
assertThatThrownBy(() -> enhancer.applySorting(sort, "p")) //
.isInstanceOf(InvalidDataAccessApiUsageException.class);
}
I'm simply trying to apply the same safeguards in our parser code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please have the same for JPQL? It's the same topic, after all. Please, also rebase this PR.
Original: #2863