Skip to content

ebean-core#3686: findCount with formula join and subquery ORDER BY produces invalid SQL#3729

Merged
rbygrave merged 1 commit intoebean-orm:masterfrom
LeComptoirDesPharmacies:fix/3686-findcount-order-by
Mar 27, 2026
Merged

ebean-core#3686: findCount with formula join and subquery ORDER BY produces invalid SQL#3729
rbygrave merged 1 commit intoebean-orm:masterfrom
LeComptoirDesPharmacies:fix/3686-findcount-order-by

Conversation

@thomas-lcdp
Copy link
Copy Markdown
Contributor

@thomas-lcdp thomas-lcdp commented Mar 26, 2026

The lastIndexOf(" order by ") in buildRowCountQuery matched ORDER BY clauses inside nested subqueries (e.g. IN sub-selects), stripping their closing parenthesis and producing unbalanced SQL.

Replace with lastTopLevelOrderBy() which tracks parenthesis depth and only matches ORDER BY at the top level of the query.

issue : #3686

…untQuery to avoid breaking nested subqueries
@rbygrave rbygrave added this to the 16.4.0 milestone Mar 27, 2026
@rbygrave rbygrave merged commit d144273 into ebean-orm:master Mar 27, 2026
1 check passed
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.

2 participants