Repository navigation
Hint at quoting when an unquoted path is used as a table name - #966
Merged
Merged
Conversation
`dirsql 'SELECT * FROM ./'` fails with SQLite's raw syntax error, which says nothing about the missing quotes. Pin the hint that should carry the fix, plus the negative control that an ordinary syntax error stays bare. Refs #951 skip-changelog: red tests only; no source change yet Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QmQHSMTjNCmjKzhyfuHXdL
`SELECT * FROM ./` dies in SQLite's parser -- `./` is punctuation, not an identifier -- so it never reaches the `no such table` error the path-table fallback rides on, and the user sees only `near ".": syntax error`. `query()` now widens SQLite's reported error offset over the surrounding path characters and appends the quoting hint when the recovered token holds a `/`. Widening matters in both directions: `FROM ./` rejects the leading `.` while `FROM src/main.rs` rejects the `/` in the middle, and the same token comes back either way. Detection stays conservative -- a token with no `/`, an error SQLite reports without a token offset, and an index with no path-table root (where quoting would fail too) are all left exactly as they were. Fixes #951 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QmQHSMTjNCmjKzhyfuHXdL
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.
Fixes #951
dirsql 'SELECT * FROM ./'died on SQLite's raw syntax error, which says nothing about the missing quotes:./is punctuation to SQLite's parser, so the statement dies at prepare time and never reaches theno such tableerror the whole path-table fallback rides on — which is why none of the existing path-table hints could fire either.Now:
How it works
All of it lands in the shared Rust core (
packages/rust/src/db.rs), so both bindings and the CLI inherit it with no per-binding surface and no SDK signature changes.Error::SqlInputError { sql, offset, .. }, whereoffsetis the byte offset of the token SQLite rejected.path_token_at(sql, offset)widens over path characters in both directions. This matters both ways:FROM ./rejects the leading., whileFROM src/main.rsrejects the/in the middle — the same token comes back either way./, per the issue's "detection can be conservative".return Err(error)arm ofquery's prepare loop, reusing the existingDbError::PathTablevariant — no new public enum variant. Gated onpath_table_rootbeing set, since without a root a quoted path would fail too and the hint would be a dead end.Red → green
62afc68pushed the failing tests alone. Rust CI went red on exactly the new assertion —expected the quoting hint, got: dirsql query: SQLite error: near ".": syntax error in SELECT * FROM ./ at offset 14— with the negative controls green in the same run.a4c7c1dadded the implementation; Rust CI flipped to green.Tests added: 3 integration (
tests/path_table_query.rs), 2 e2e (tests/path_table_cli_e2e.rs), 13 colocated unit (src/db.rs). Two of them are negative controls pinning the conservative side.Manual verification
Built
target/debug/dirsqland ran it against a real temp directory:SELECT * FROM ./did you mean "./"?SELECT basename FROM "./"[{"basename":"a.md"},…], exit 0 — the fix the hint names worksSELECT * FROM docs/a.mddid you mean "docs/a.md"?(mid-path offset widened)SELECT * FROM ..//~/notes//var/log/*.logSELECT * FROMincomplete input, no hintSELECT * FROM usrsno such table: usrs, no hintSELECT size/1024 FROM "./" WHER size > 0SELECT (size/1024 FROM "./"Also exercised through both bindings, which return the identical two-line message:
await db.query('SELECT * FROM ./')→RuntimeError: SQLite error: near ".": syntax error … / hint: paths used as table names must be quoted; did you mean "./"?new DirSQL({root}).query("SELECT * FROM ./")One accepted false positive: a contrived, already-broken query such as
SELECT * FROM "./" GROUP a/bhints ona/b. The original error is still shown in full and the hint is additive.E2E Verification
cargo test --workspace --features cli; see note below)packages/pythone2e attestation refreshed (5e319db)packages/tse2e attestation refreshed (63b83d3) — apackages/rust/srcchange stales bothcargo test --workspace --features clicd packages/python && uv run python -m pytest tests/e2e/ -x -qcd packages/ts && pnpm test:e2ecargo clippy --workspace -- -D warnings,cargo fmt --all -- --checknpx -y testing-conventions unit colocated-test|unit lint --language rust … packages/rustnpx -y testing-conventions unit coverage --language rust packages/rust/src(on nightly)tests/vtab.rs::unreadable_file_yields_null_content_without_erroring_the_rowchmods a fixture0o000and expects the read to fail, but the sandbox runs as uid 0, which bypasses file permissions. Confirmed pre-existing by stashing this branch's source change and re-running; it passes in CI.Changelog / Migrations
packages/rust/changelog.d/2026-08-20-unquoted-path-table-hint.mdParity
PARITY.mdupdated with an "Unquoted-path hint (#951)" entry. Not drift — the change is in the shared core, so all three SDKs and the CLI receive the identical message simultaneously. Verified empirically across the PyO3 and napi boundaries (above), so no follow-up issues are needed.