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

Function canOptimizeOrExpression

packages/db/src/utils/index-optimization.ts:720–731  ·  view source on GitHub ↗

* Checks if an OR expression can be optimized

(expression: BasicExpression, collection: CollectionLike<T, TKey>)

Source from the content-addressed store, hash-verified

718 * Checks if an OR expression can be optimized
719 */
720function canOptimizeOrExpression<
721 T extends object,
722 TKey extends string | number,
723>(expression: BasicExpression, collection: CollectionLike<T, TKey>): boolean {
724 if (expression.type !== `func` || expression.args.length < 2) {
725 return false
726 }
727
728 // Every disjunct must be optimizable, otherwise the union would miss
729 // rows matched only by the non-optimizable disjuncts
730 return expression.args.every((arg) => canOptimizeExpression(arg, collection))
731}
732
733/**
734 * Optimizes IN array expressions

Callers 1

canOptimizeExpressionFunction · 0.85

Calls 1

canOptimizeExpressionFunction · 0.85

Tested by

no test coverage detected