Skip to content

Support sorting by aliased columns #2863

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

Closed
gregturn opened this issue Mar 15, 2023 · 1 comment
Closed

Support sorting by aliased columns #2863

gregturn opened this issue Mar 15, 2023 · 1 comment
Assignees
Labels
in: query-parser Everything related to parsing JPQL or SQL type: enhancement A general enhancement type: task A general task

Comments

@gregturn
Copy link
Contributor

For queries where a column is an alias:

select AVG(p.points) as avg
from Player p

...when we have a Sort.by("avg"), it should NOT append order by p.avg but instead simply have order by avg.

Essentially, anywhere we have an aliased column or value, that should be supported in the order by operations.

@gregturn gregturn added type: task A general task type: enhancement A general enhancement in: query-parser Everything related to parsing JPQL or SQL labels Mar 15, 2023
gregturn added a commit that referenced this issue Mar 15, 2023
If a projection of an HQL query is aliased, be that a function call or a simply alias, apply sorting should NOT result in that order parameter having the primary FROM clause's alias prefixed to.

Resolves #2863.
Related: #2626, #2322.
gregturn added a commit that referenced this issue Mar 15, 2023
If a projection of an HQL query is aliased, be that a function call or a simply alias, apply sorting should NOT result in that order parameter having the primary FROM clause's alias prefixed to.

Resolves #2863.
Related: #2626, #2322.
gregturn added a commit that referenced this issue Mar 15, 2023
If a projection of an HQL query is aliased, be that a function call or a simply alias, apply sorting should NOT result in that order parameter having the primary FROM clause's alias prefixed to.

Resolves #2863.
Related: #2626, #2322.
@gregturn gregturn linked a pull request Mar 22, 2023 that will close this issue
@gregturn gregturn self-assigned this Mar 22, 2023
gregturn added a commit that referenced this issue Apr 5, 2023
If a projection of either an HQL or JPQL query is aliased, applied sorting should NOT result in that order parameter having the primary FROM clause's alias prefix to it. Same goes for function-based order by arguments.

Resolves #2863.
Related: #2626, #2322.
Original pull request: #2865.
gregturn added a commit that referenced this issue Apr 5, 2023
If a projection of either an HQL or JPQL query is aliased, do NOT prefix the FROM clause's alias prefix to any relevant applied sorting. Same for function-based order by arguments.

Resolves #2863.
Related: #2626, #2322, #1655.
Original pull request: #2865.
@gregturn gregturn added this to the 3.1 RC1 (2023.0.0) milestone Apr 5, 2023
@SharkFourSix
Copy link

Anyway to do this in version 2? I think releasing this fix in SB3 forces people to deal with the migration hell (refactoring thousands of import from javax.* to jarkata,*, etc) to SB3. Not a very good look :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: query-parser Everything related to parsing JPQL or SQL type: enhancement A general enhancement type: task A general task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants