test: failing tests for AND/OR queries mixing indexed and non-indexed conditions#1581
test: failing tests for AND/OR queries mixing indexed and non-indexed conditions#1581kevin-dp wants to merge 2 commits into
Conversation
…d non-indexed conditions These tests assert the expected results of currentStateAsChanges for AND/OR where clauses that combine conditions on indexed fields with conditions that cannot be served by an index. They currently fail. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds tests ensuring date ChangesComplex Query Optimization & Date-bound Tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
More templates
@tanstack/angular-db
@tanstack/browser-db-sqlite-persistence
@tanstack/capacitor-db-sqlite-persistence
@tanstack/cloudflare-durable-objects-db-sqlite-persistence
@tanstack/db
@tanstack/db-ivm
@tanstack/db-sqlite-persistence-core
@tanstack/electric-db-collection
@tanstack/electron-db-sqlite-persistence
@tanstack/expo-db-sqlite-persistence
@tanstack/node-db-sqlite-persistence
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/react-native-db-sqlite-persistence
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/tauri-db-sqlite-persistence
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Adds expected-behaviour tests for range conditions: - compound ranges sharing a boundary value must apply the strictest bound regardless of argument order, including for date values - one-sided compound ranges must return the matching rows - strict comparisons (gt) on date fields must exclude the boundary row Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Adds seven unit tests to
collection-indexes.test.tsthat assert the expected results ofcurrentStateAsChangesforwhereclauses that the index optimizer currently gets wrong. All tests are written purely in terms of expected behaviour.Mixing indexed and non-indexed conditions (e.g.
length(name) > 6):Range boundary handling:
4. Strictest lower bound —
gte(age, 25) AND gt(age, 25)must reduce toage > 25regardless of argument order. Currently the inclusive bound wins.5. Strictest upper bound —
lte(age, 30) AND lt(age, 30)must reduce toage < 30. Currently the inclusive bound wins.6. Date bounds at the same value — distinct
Dateinstances representing the same time must be treated as equal when picking the strictest bound. (Also exercises one-sided compound ranges, which currently return an empty result.)7. Strict comparisons on date fields —
gt(createdAt, date)must exclude the boundary row. Currently the BTree index includes it because it compares the normalized indexed value against the rawDate.mainby design — they pin down the expected behaviour. The follow-up PR #1582 provides the fixes that make them pass.🤖 Generated with Claude Code