Request: SQLite compiler falls back to full-table reads for zero/one-argument AND and OR
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- sqlite, typescript
- Lĩnh vực
- database
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.9k
- Fork
- 268
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 178
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/db
-
Persisted on-demand Electric collection enters error after a committed transaction waits across subset hydrationCó thể đã có người làm @alec-watts đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
TanStack/db#2036 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SQLite persistence silently serializes Temporal values as {}, breaking hydration and subset queriesCó thể đã có người làm @KyleAMathews đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
Maintainer thường phản hồi trong vòng 1 ngày
-
useLiveInfiniteQuery commits an empty first render over a synchronously loaded collection (useLiveQuery doesn't)Có thể đã có người làm @KyleAMathews đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
TanStack/db#1972 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
umbraco/Umbraco-CMS-MCP-Dev#512 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
wimpysworld/sidra#290 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
defuFn invokes function values for inherited default propertiesCó thể đã có người làm @xiehuanyi đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
feature request good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
TabularisDB/tabularis#853 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 85/100
capricorn86/happy-dom#2474 ·
Maintainer thường phản hồi trong vòng 2 ngày