* Extracts the source alias from a join expression
(expr: BasicExpression)
| 429 | * Extracts the source alias from a join expression |
| 430 | */ |
| 431 | function getSourceAliasesFromExpression(expr: BasicExpression): Set<string> { |
| 432 | switch (expr.type) { |
| 433 | case `ref`: |
| 434 | // PropRef path has the source alias as the first element |
| 435 | return new Set(expr.path[0] ? [expr.path[0]] : []) |
| 436 | case `func`: { |
| 437 | // For function expressions, we need to check if all arguments refer to the same source |
| 438 | const sourceAliases = new Set<string>() |
| 439 | for (const arg of expr.args) { |
| 440 | for (const alias of getSourceAliasesFromExpression(arg)) { |
| 441 | sourceAliases.add(alias) |
| 442 | } |
| 443 | } |
| 444 | return sourceAliases |
| 445 | } |
| 446 | default: |
| 447 | // Values (type='val') don't reference any source |
| 448 | return new Set() |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Processes the join source (collection or sub-query) |
no test coverage detected