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

Function normalizeExpressionPaths

packages/db/src/query/compiler/expressions.ts:21–53  ·  view source on GitHub ↗
(
  whereClause: BasicExpression<boolean>,
  collectionAlias: string,
)

Source from the content-addressed store, hash-verified

19 * // Output: ref with path ['id']
20 */
21export function normalizeExpressionPaths(
22 whereClause: BasicExpression<boolean>,
23 collectionAlias: string,
24): BasicExpression<boolean> {
25 const tpe = whereClause.type
26 if (tpe === `val`) {
27 return new Value(whereClause.value)
28 } else if (tpe === `ref`) {
29 const path = whereClause.path
30 if (Array.isArray(path)) {
31 if (path[0] === collectionAlias && path.length > 1) {
32 // Remove the table alias from the path for single-collection queries
33 return new PropRef(path.slice(1))
34 } else if (path.length === 1 && path[0] !== undefined) {
35 // Single field reference
36 return new PropRef([path[0]])
37 }
38 }
39 // Fallback for non-array paths
40 return new PropRef(Array.isArray(path) ? path : [String(path)])
41 } else {
42 // Recursively convert all arguments
43 const args: Array<BasicExpression> = []
44 for (const arg of whereClause.args) {
45 const convertedArg = normalizeExpressionPaths(
46 arg as BasicExpression<boolean>,
47 collectionAlias,
48 )
49 args.push(convertedArg)
50 }
51 return new Func(whereClause.name, args)
52 }
53}
54
55export function normalizeOrderByPaths(
56 orderBy: OrderBy,

Callers 3

startMethod · 0.85
normalizeOrderByPathsFunction · 0.85
subscribeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected