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

Function isRangeOrderingDivergent

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

* Whether a range predicate on this operand would use an index ordering that * differs from the WHERE evaluator's relational operators, so an index range * lookup could omit genuine matches that re-filtering cannot recover. * * The evaluator compares with JS relational operators (extended with

(
  value: unknown,
  collection: CollectionLike<any, any>,
)

Source from the content-addressed store, hash-verified

152 * cases handled by re-filtering ({@link isExactComparisonValue}).
153 */
154function isRangeOrderingDivergent(
155 value: unknown,
156 collection: CollectionLike<any, any>,
157): boolean {
158 switch (typeof value) {
159 case `number`:
160 case `bigint`:
161 case `boolean`:
162 return false
163 case `string`:
164 return usesLocaleStringSort(collection)
165 case `object`: {
166 if (value === null) return false
167 // Dates order consistently with the evaluator: valid Dates by time, and
168 // invalid Dates as the greatest value under PostgreSQL float semantics.
169 return !(value instanceof Date)
170 }
171 default:
172 return false
173 }
174}
175
176/**
177 * Whether a range predicate (gt/gte/lt/lte) on this operand can be safely

Callers 1

canRangeOptimizeFunction · 0.85

Calls 1

usesLocaleStringSortFunction · 0.85

Tested by

no test coverage detected