Skip to content
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

#3552 Column alias required for SQL Server + findCount + distinct #3553

Merged
merged 2 commits into from
Feb 8, 2025

Conversation

rbygrave
Copy link
Member

@rbygrave rbygrave commented Feb 8, 2025

  • Modifies CQueryBuilder with the main fix which is to use the database platform selectCountWithColumnAlias for all distinct queries [and later disable it for single column case]

  • Modifies SqlTreeBuilder because we need to NOT use the column alias for the count distinct SINGLE COLUMN case. So change here to:

    • build the root SqlTreeNode first as part of constructor

    • use rootNode.isSingleProperty() to NOT use column alias for the single column case

    • Hence need to initialise DefaultDbSqlContext AFTER the root SqlTreeNode

    • Modifies DefaultDbSqlContext with no effective change, just columnIndex++ ONLY when we are actually using column alias

  • Modifies H2Platform to also use selectCountWithColumnAlias true

- Modifies CQueryBuilder with the main fix which is to use the database platform selectCountWithColumnAlias for all distinct queries [and later disable it for single column case]

- Modifies SqlTreeBuilder because we need to NOT use the column alias for the count distinct SINGLE COLUMN case. So change here to:
  - build the root SqlTreeNode first as part of constructor
  - use rootNode.isSingleProperty() to NOT use column alias for the single column case
  - Hence need to initialise DefaultDbSqlContext AFTER the root SqlTreeNode

  - Modifies DefaultDbSqlContext with no effective change, just columnIndex++ ONLY when we are actually using column alias

 - Modifies H2Platform to also use selectCountWithColumnAlias true
Plus fix TestRowCount for Oracle platform
@rbygrave rbygrave added this to the 14.8.2 milestone Feb 8, 2025
@rbygrave rbygrave merged commit 60aa899 into master Feb 8, 2025
6 checks passed
@rbygrave rbygrave deleted the feature/3553 branch February 8, 2025 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant