Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Request: SQLite IN-list chunking still exceeds the statement-wide parameter limit

已关闭
#1,993 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
sqlite, typescript
领域
database

调研方向

Start by tracing the SQLite persistence compiler from adapter.loadSubset and reproduce the issue with the Node SQLite harness using a variable limit of 999. Inspect how composed predicates contribute bound parameters, including index expressions and partial-index predicates. Done means each executed statement stays within SQLite’s parameter limit while preserving typed comparisons, bigint precision, and literal arrays in index definitions.

由索引模型根据 Issue 内容生成。

描述

Problem

The SQLite persistence compiler splits large IN arrays into smaller clauses joined with OR, but keeps all their bound parameters in one SQL statement.

SQLite's bound-parameter limit applies to the entire statement. Splitting the clauses therefore does not prevent the limit from being exceeded.

Multiple smaller IN predicates can also exceed the limit when composed into one query.

Versions

  • @tanstack/db-sqlite-persistence-core: 0.4.0
  • @tanstack/browser-db-sqlite-persistence: 0.2.25
  • @tanstack/db: 0.11.0

The same compilation strategy is present in upstream main inspected on October 2, 2026.

Reproduction

Use a SQLite-backed adapter with the connection's variable limit set to 999. For example, our Node SQLite harness uses:

new DatabaseSync(':memory:', {
  limits: { variableNumber: 999 },
})

After initializing a collection, request:

import { IR } from '@tanstack/db'

const ids = Array.from({ length: 1_000 }, (_, i) => `issue-${i}`)

await adapter.loadSubset(collectionId, {
  where: new IR.Func('or', [
    new IR.Func('in', [
      new IR.PropRef(['issueId']),
      new IR.Value(ids),
    ]),
    new IR.Func('in', [
      new IR.PropRef(['relatedIssueId']),
      new IR.Value(ids),
    ]),
  ]),
})

Source inspection shows that this produces approximately 2,000 list parameters in one statement, despite the internal chunking. That exceeds the configured limit.

Expected behavior

Bound the total number of parameters in each executed statement, including parameters from composed predicates.

Downstream workaround

We bind each list as one JSON array and compile runtime predicates as:

field IN (SELECT value FROM json_each(?))

An alternative implementation would also be welcome. Important compatibility requirements include preserving typed comparisons and signed 64-bit bigint precision.

Index expressions and partial-index predicates need separate handling: SQLite does not permit these subqueries in index definitions.

Existing downstream tests cover 50,582 IDs across two fields, bigint values beyond JavaScript's safe-integer range, and literal arrays in index definitions. They were not rerun for this source-inspection report.

#810 concerns Electric HTTP request-size limits; this report concerns local SQLite statement parameters.

主要语言
TypeScript
星标
3.9k
派生
268
平均合并
1 天 4 小时
30 天内合并 PR
178

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/db 的其他 Issue

查看 TanStack/db 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。