Request: SQLite compiler falls back to full-table reads for zero/one-argument AND and OR
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- sqlite, typescript
- Domínio
- database
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 3.9k
- Forks
- 268
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 212
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/db
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
electric-db-collection: on-demand + persistence fails after relaunch with "Snapshot requests are not supported in full mode"Talvez já em andamento @KyleAMathews assumiu há 2 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
TanStack/db#1972 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 45/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/db
Issues semelhantes
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 75/100
lingdojo/kana-dojo#32018 · 1 comentário · 5 reações ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
paperclipai/paperclip#15751 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
BuilderIO/agent-native#7275 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia