MCPcopy Index your code
hub / github.com/TanStack/db / compileExpressionInternal

Function compileExpressionInternal

packages/db/src/query/compiler/evaluators.ts:110–134  ·  view source on GitHub ↗

* Internal unified expression compiler that handles both namespaced and single-row evaluation

(
  expr: BasicExpression,
  isSingleRow: boolean,
)

Source from the content-addressed store, hash-verified

108 * Internal unified expression compiler that handles both namespaced and single-row evaluation
109 */
110function compileExpressionInternal(
111 expr: BasicExpression,
112 isSingleRow: boolean,
113): (data: any) => any {
114 switch (expr.type) {
115 case `val`: {
116 // For constant values, return a function that just returns the value
117 const value = expr.value
118 return () => value
119 }
120
121 case `ref`: {
122 // For references, compile based on evaluation mode
123 return isSingleRow ? compileSingleRowRef(expr) : compileRef(expr)
124 }
125
126 case `func`: {
127 // For functions, use the unified compiler
128 return compileFunction(expr, isSingleRow)
129 }
130
131 default:
132 throw new UnknownExpressionTypeError((expr as any).type)
133 }
134}
135
136/**
137 * Compiles a reference expression into an optimized evaluator

Callers 3

compileExpressionFunction · 0.85
compileFunctionFunction · 0.85

Calls 3

compileSingleRowRefFunction · 0.85
compileRefFunction · 0.85
compileFunctionFunction · 0.70

Tested by

no test coverage detected