fix(sqlite-persistence): preserve expression index use - #1867
KyleAMathews wants to merge 6 commits into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthrough
ChangesSQLite expression-index planning
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The adapter emits canonical SQL literals for persisted JSON reference paths while comparison values remain bound, and the reported validation passes with no actionable merge-blocking risk evidenced. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
🛠️ Fix failing CI checks 💡
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 |
…ion-index-oracle # Conflicts: # docs/contributing/oracle-coverage.md
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/react-router-with-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/tauri-db-sqlite-persistence
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 165 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 7.34 kB ℹ️ View Unchanged
|
Compile validated JSON reference paths as canonical SQLite literals so runtime
predicates match persisted expression indexes. Queries keep returning the same
rows, but SQLite can now use the intended index instead of scanning the
collection table.
🎯 Changes
Root cause
Persisted index DDL embedded the JSON path as a SQL literal, while runtime
reference filters compiled the same path as a bound parameter. SQLite requires
an indexed expression to match the predicate expression structurally;
json_extract(value, ?)is semantically correct but cannot use an index definedon
json_extract(value, '$.path').Approach
the existing SQLite literal helper.
SQL, independently checks rows, and replays the query through
EXPLAIN QUERY PLANto require the named expression index.Key invariants
literalized.
expression for plain and tagged values.
false greens.
Non-goals
null/date/bigint/tagged-value coercion semantics.
Trade-offs
JSON path shapes become part of the generated SQL text rather than path
bindings. That is required for SQLite expression-index compatibility; scalar
filter values remain parameterized.
✅ Checklist
🚀 Release Impact
Verification
After merging current
main, local results are: 96 SQLite persistence-coretests passed; all 45 Node persistence tests passed, including all 3
expression-index oracle tests; both package TypeScript checks and builds
passed; and ESLint, Prettier, the commit hook, and diff validation passed.
Files changed
sqlite-core-adapter.ts: compile validated ref paths as canonical SQLiteliterals.
expression-index-oracle.test.ts: verify rows and the real named-index queryplan across fixed and generated cases.
Part of #1659
Summary by CodeRabbit
Bug Fixes
Documentation
Tests