Skip to content

Detect COUNT(*) function alias in QueryUtils.#4249

Open
config25 wants to merge 1 commit intospring-projects:mainfrom
config25:fix/gh-4242-count-star-alias
Open

Detect COUNT(*) function alias in QueryUtils.#4249
config25 wants to merge 1 commit intospring-projects:mainfrom
config25:fix/gh-4242-count-star-alias

Conversation

@config25
Copy link
Copy Markdown

@config25 config25 commented May 7, 2026

Include the asterisk character in the FUNCTION_PATTERN argument
character class so that the COUNT(*) AS <alias> form is detected by
QueryUtils.getFunctionAliases.

Without this, DefaultQueryEnhancer.applySorting prefixes the alias
with the root entity alias and produces invalid SQL such as
ORDER BY u.cnt instead of ORDER BY cnt.

Adds a regression test (discoversCountStarFunctionAlias) covering the
issue's reproducer and the GROUP BY example from the issue body.

Closes #4242

Include the asterisk character in the FUNCTION_PATTERN argument character
class so that the COUNT(*) AS <alias> form is detected by
QueryUtils.getFunctionAliases. Without this, DefaultQueryEnhancer's
applySorting prefixes the alias with the root entity alias and produces
invalid SQL such as ORDER BY u.cnt instead of ORDER BY cnt.

Closes spring-projects#4242

Signed-off-by: Young-ho Kim <yhkim052556@naver.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FUNCTION_PATTERN character class omits *, so COUNT(*) AS alias is not detected

2 participants