Request: SQLite compiler falls back to full-table reads for zero/one-argument AND and OR
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 68/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- sqlite, typescript
- Domaine
- database
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 4k
- Forks
- 277
- Merge moyen
- 18 h 49 min
- PR mergées (30 j)
- 224
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TanStack/db
-
`Collection.currentStateAsChanges` JSDoc examples don’t match `CurrentStateAsChangesOptions`Ouverte
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
OfflineExecutor.dispose() never settles pendingTransactionPromisesPeut-être pris @Claire-ovo l’a pris il y a 1 jour. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
TanStack/db#2254 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 28/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de TanStack/db
Issues similaires
-
area: server priority: P3 type: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
appandflow/stim#4538 ·
Les mainteneurs répondent en général sous 1 jour
-
[BUG] Published Docker images lack the redis extra: HEADROOM_COMPRESS_SESSION_STORE stops startupPeut-être pris @AlessandroSpallina l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
headroomlabs-ai/headroom#4513 ·
Les mainteneurs répondent en général sous 1 jour
-
bug extension extension: obsidian platform: Windows
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
raycast/extensions#32838 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
copy design-review mac P3
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
tosunlab/hisarapp-core#510 ·
-
bug priority-medium to-agent
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour