Skip to content

Commit

Permalink
fix: wildcard expand + group by doesnt skip expand
Browse files Browse the repository at this point in the history
  • Loading branch information
patricebender committed Jan 22, 2025
1 parent fe4f66b commit 8318014
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions db-service/lib/cqn4sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,10 @@ function cqn4sql(originalQuery, model) {
// columns of the expand must be in the groupBy
if (transformedQuery.SELECT.groupBy) {
const baseRef = column.$refLinks[0].definition.SELECT || ref

return _subqueryForGroupBy(column, baseRef, columnAlias)
const wildcardIndex = column.expand.findIndex(e => e === '*')
if (wildcardIndex === -1) {
return _subqueryForGroupBy(column, baseRef, columnAlias)
}
}

// we need to respect the aliases of the outer query, so the columnAlias might not be suitable
Expand Down Expand Up @@ -877,11 +879,6 @@ function cqn4sql(originalQuery, model) {

// to be attached to dummy query
const elements = {}
const wildcardIndex = column.expand.findIndex(e => e === '*')
if (wildcardIndex !== -1) {
// expand with wildcard vanishes as expand is part of the group by (OData $apply + $expand)
return null
}
const expandedColumns = column.expand.flatMap(expand => {
if (!expand.ref) return expand
const fullRef = [...baseRef, ...expand.ref]
Expand Down

0 comments on commit 8318014

Please sign in to comment.