Repository navigation
fix(server): refuse a query on a column the table does not have - #63
Merged
Merged
Conversation
SQLite reads a double quoted name that matches no column as a string literal, in WHERE and ORDER BY alike, so a sub, fetch or snapshot read naming an unknown column returned every row or none, while the evaluator that decides deltas read the column as undefined. SQLite also resolves a name in another case and rowid, which a row from SELECT * never carries. compileSubsetQuery now returns the columns a query names, and the mixin refuses one not in pragma_table_xinfo (exact match), read only when the query names a column and never cached across queries. A sub gets reset, a fetch the empty page, readSyncSnapshot throws. A restored sub whose where names a dropped column closes its socket with 1011, like one that no longer compiles. ADR-0013 amendment 2026-11-17. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n columns The one cursor case named the unknown column in both halves, so checking only the page statement's columns still passed every test while the ties statement returned every row. Each half is now pinned alone. One readSyncSnapshot case goes through the RPC stub, where the caller gets a plain Error whose message starts with UnsupportedPredicateError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ADR amendment now says what a client goes through when a restored sub names a dropped column, why running the whole compiler on restore is safe within one build, the rows read per column check, that the error class does not survive the RPC, and what a dropped table gives. The README lists the refusal under known limitations. The mixin drops the `hidden != 1` filter, which no synced table can reach, and its restore comment says the same as the ADR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges the fix: the column names a query refers to are checked against the table when the query is compiled, on every path that takes a client where or orderBy, and on restore after a wake. Adds the changelog entry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
whereororderBythat names a column the table does not have was not refused. The SQL compiler writes a column as a double quoted name, and SQLite in a Durable Object reads an unknown quoted name as a string literal. Soeq(nope, "nope")returned every row in the snapshot, while the client's evaluator, which decides the deltas, matched none. A typo in a column name gave an app a wrong list that looked right. It reached every comparison,in,like,orderBy,fetchandreadSyncSnapshot.What changed
resetwith nothing registered for asub, an empty page for afetch, and a rejection forreadSyncSnapshot. The server logs one line.rowidare refused too. SQLite resolvesBODYtobodyand acceptsrowid, but a row on the client has neither key.Things to know
Verification
@tanstack/db1.0.0-rc.1.5 and 0.8.6.Not verified: whether Cloudflare bills the rows read from the pragma, and the client's steps after a restore close, which were checked by reading the code.
The decision is a dated amendment to ADR-0013.
🤖 Generated with Claude Code