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

Function splitAndClausesRecursive

packages/db/src/query/optimizer.ts:561–575  ·  view source on GitHub ↗
(
  clause: BasicExpression<boolean>,
)

Source from the content-addressed store, hash-verified

559
560// Helper function for recursive splitting of BasicExpression arrays
561function splitAndClausesRecursive(
562 clause: BasicExpression<boolean>,
563): Array<BasicExpression<boolean>> {
564 if (clause.type === `func` && clause.name === `and`) {
565 // Recursively split nested AND clauses to handle complex expressions
566 const result: Array<BasicExpression<boolean>> = []
567 for (const arg of clause.args as Array<BasicExpression<boolean>>) {
568 result.push(...splitAndClausesRecursive(arg))
569 }
570 return result
571 } else {
572 // Preserve non-AND clauses as-is (including OR clauses)
573 return [clause]
574 }
575}
576
577/**
578 * Step 2: Analyze which table sources a WHERE clause touches.

Callers 2

splitAndClausesFunction · 0.85
applyOptimizationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected