Skip to content

HHH-19396 cannot select the same column twice with different aliases while using cte #10158

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cigaly
Copy link
Contributor

@cigaly cigaly commented May 15, 2025

Jira issue HHH-19464

When creating SqlAstQueryPartProcessingStateImpl in method org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter#visitQuerySpec parameter deduplicateSelectionItems must be set to false (see comment in moved code block)

When selectStatement contains same column more than once in method org.hibernate.query.sqm.tree.cte.SqmCteTable#createStatementTable, SqmCteTable constructor will be unable to properly resolve aliases. To prevent this alias in select clause selection should be used if exist, one from selectable node should be used otherwise.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-19396

cigaly added 2 commits May 15, 2025 10:36
… SqlAstQueryPartProcessingStateImpl

          Selection items representing same column in (sub)query will be represented with single instance, this will hide real alias
@cigaly cigaly changed the title Hhh 19396 cannot select the same column twice with different aliases while using cte HHH-19396 cannot select the same column twice with different aliases while using cte May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant