@@ -408,6 +408,7 @@ function cqn4sql(originalQuery, model) {
408
408
const last = $refLinks ?. [ $refLinks . length - 1 ]
409
409
if ( last && ! last . skipExpand && last . definition . isAssociation ) {
410
410
const expandedSubqueryColumn = expandColumn ( col )
411
+ if ( ! expandedSubqueryColumn ) return [ ]
411
412
setElementOnColumns ( expandedSubqueryColumn , col . element )
412
413
res . push ( expandedSubqueryColumn )
413
414
} else if ( ! last ?. skipExpand ) {
@@ -863,7 +864,7 @@ function cqn4sql(originalQuery, model) {
863
864
* @param {Object } column - To expand.
864
865
* @param {Array } baseRef - The base reference for the expanded column.
865
866
* @param {string } subqueryAlias - The alias of the `expand` subquery column.
866
- * @returns {Object } - The subquery object.
867
+ * @returns {Object } - The subquery object or null if the expand has a wildcard .
867
868
* @throws {Error } - If one of the `ref`s in the `column.expand` is not part of the GROUP BY clause.
868
869
*/
869
870
function _subqueryForGroupBy ( column , baseRef , subqueryAlias ) {
@@ -873,7 +874,13 @@ function cqn4sql(originalQuery, model) {
873
874
874
875
// to be attached to dummy query
875
876
const elements = { }
877
+ const wildcardIndex = column . expand . findIndex ( e => e === '*' )
878
+ if ( wildcardIndex !== - 1 ) {
879
+ // expand with wildcard vanishes as expand is part of the group by (OData $apply + $expand)
880
+ return null
881
+ }
876
882
const expandedColumns = column . expand . flatMap ( expand => {
883
+ if ( ! expand . ref ) return expand
877
884
const fullRef = [ ...baseRef , ...expand . ref ]
878
885
879
886
if ( expand . expand ) {
@@ -1404,8 +1411,7 @@ function cqn4sql(originalQuery, model) {
1404
1411
if ( list . every ( e => e . val ) )
1405
1412
// no need for transformation
1406
1413
transformedTokenStream . push ( { list } )
1407
- else
1408
- transformedTokenStream . push ( { list : getTransformedTokenStream ( list , $baseLink ) } )
1414
+ else transformedTokenStream . push ( { list : getTransformedTokenStream ( list , $baseLink ) } )
1409
1415
}
1410
1416
} else if ( tokenStream . length === 1 && token . val && $baseLink ) {
1411
1417
// infix filter - OData variant w/o mentioning key --> flatten out and compare each leaf to token.val
@@ -2204,10 +2210,7 @@ function cqn4sql(originalQuery, model) {
2204
2210
const xpr = search
2205
2211
const searchFunc = {
2206
2212
func : 'search' ,
2207
- args : [
2208
- { list : searchIn } ,
2209
- xpr . length === 1 && 'val' in xpr [ 0 ] ? xpr [ 0 ] : { xpr } ,
2210
- ] ,
2213
+ args : [ { list : searchIn } , xpr . length === 1 && 'val' in xpr [ 0 ] ? xpr [ 0 ] : { xpr } ] ,
2211
2214
}
2212
2215
return searchFunc
2213
2216
} else {
0 commit comments