Request: SQLite compiler falls back to full-table reads for zero/one-argument AND and OR
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- sqlite, typescript
- 领域
- database
调研方向
Start by locating the SQLite persistence SQL compiler and inspect its handling of and/or expressions with zero or one argument. Check the existing compiler tests and the downstream regression assertion for the generated SQL. Done means one-argument predicates compile directly, empty and/or become true/false predicates, and unsupported children retain fallback behavior.
由索引模型根据 Issue 内容生成。
描述
Problem
The SQLite persistence compiler marks and and or expressions with fewer than two arguments as unsupported.
loadSubsetInternal then omits the SQL WHERE clause, reads and deserializes the entire collection, and filters the rows in JavaScript.
Results can still be correct, but a selective query—or a query that should return no rows—does unnecessary work over the whole cached table.
Versions
@tanstack/db-sqlite-persistence-core:0.4.0@tanstack/browser-db-sqlite-persistence:0.2.25@tanstack/db:0.11.0
The same compiler checks are present in upstream main inspected on October 2, 2026.
Reproduction
Populate a persisted collection with many rows and instrument the SQL passed to its driver:
import { IR } from '@tanstack/db'
const predicate = new IR.Func('eq', [
new IR.PropRef(['id']),
new IR.Value('row-1'),
])
await adapter.loadSubset(collectionId, {
where: new IR.Func('and', [predicate]),
})
await adapter.loadSubset(collectionId, {
where: new IR.Func('or', [predicate]),
})
await adapter.loadSubset(collectionId, {
where: new IR.Func('or', []),
})
Source inspection shows that each expression is rejected by the SQL compiler. The resulting collection read has no WHERE clause.
The empty or case is particularly wasteful: the final result is empty, but the adapter first reads every persisted row.
Expected behavior
Compile these expressions consistently with the core evaluator:
- One-argument
andoror: compile the contained predicate. - Empty
and: compile a true predicate. - Empty
or: compile a false predicate.
Unsupported child expressions should retain the existing fallback behavior.
Downstream workaround
We add these cases to the SQLite compiler. An existing downstream regression assertion checks that an empty-result initialization query includes WHERE (0 = 1) rather than reading the entire cache.
This report is based on source inspection; downstream tests were not rerun for this report.
Related issue
#506 discusses zero/one-argument support in the public query API. This report specifically concerns SQL compilation and full-table fallback in the persistence adapter.
- 主要语言
- TypeScript
- 星标
- 3.9k
- 派生
- 268
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 148
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/db 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 50/100
TanStack/db#1992 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
perf(core): getComments() runs the approved count and the comment list as two sequential queries未关闭area/core bot:bug bot:working
难度 2/5 1-3 小时 新手友好度 76/100
emdash-cms/emdash#3905 · 2 条评论 ·
维护者通常 1 天内回复
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 90/100
lingdojo/kana-dojo#31728 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
selective-claw: freshTailTurns=0 keeps ALL turns verbatim and summarizes none (slice(-0) === slice(0))可能已有人在做 @zjncs 今天认领。 未关闭component:tokenless
难度 2/5 1-3 小时 新手友好度 80/100
agentic-os-org/ANOLISA#6112 · 1 条评论 ·
维护者通常 1 天内回复
-
bug needs triage
难度 2/5 1-3 小时 新手友好度 75/100
rjsf-team/react-jsonschema-form#5439 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复