MCPcopy Create free account
hub / github.com/TanStack/db / getSourceAliasesFromExpression

Function getSourceAliasesFromExpression

packages/db/src/query/compiler/joins.ts:431–450  ·  view source on GitHub ↗

* Extracts the source alias from a join expression

(expr: BasicExpression)

Source from the content-addressed store, hash-verified

429 * Extracts the source alias from a join expression
430 */
431function 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)

Callers 1

analyzeJoinExpressionsFunction · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected