fix(sqlite-persistence): preserve expression index use - #1867
KyleAMathews wants to merge 3 commits into
Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. 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; 3 remain after this review. 📝 WalkthroughWalkthrough
ChangesSQLite expression-index planning
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
…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.
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 defined onjson_extract(value, '$.path').Approach
EXPLAIN QUERY PLANto require the named expression index.Key invariants
Non-goals
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.
Verification
Local results: 96 SQLite persistence-core tests passed, all 3 expression-index oracle tests passed, both package TypeScript checks passed, and Prettier plus diff validation passed.
Files changed
sqlite-core-adapter.ts: compile validated ref paths as canonical SQLite literals.expression-index-oracle.test.ts: verify rows and the real named-index query plan across fixed and generated cases.Part of #1659
Summary by CodeRabbit
Bug Fixes
Documentation
Tests