Skip to content

Quote table and view names when preparing LLM context - #271

Open
hao0x1 wants to merge 1 commit into
dbcli:mainfrom
hao0x1:codex/fix-llm-table-identifiers
Open

hao0x1 wants to merge 1 commit into
dbcli:mainfrom
hao0x1:codex/fix-llm-table-identifiers

Conversation

@hao0x1

@hao0x1 hao0x1 commented Oct 1, 2026

Copy link
Copy Markdown

Description

A table named products 1 is valid in SQLite, but it makes \llm fail with near "1": syntax error while preparing sample rows. The query uses the table name without quoting it.

This quotes table and view names and escapes any double quotes inside them. The new tests use real SQLite databases with spaces, reserved words, quotes, and dots in object names. Only the external LLM command is mocked.

Related to #253. This reproduces the same error, although I couldn't check the reporter's database to confirm its cause.

The suite passes on Python 3.10 and 3.13, including runs with and without SQLean: 238 passed, with the same skips and expected/unexpected failures as main. tox -e style passes with the Ruff version pinned in CI. Type checking passes for the changed files; the full check still reports the same five existing diagnostics as main.

Codex helped with the patch and tests.

Checklist

  • I've added this contribution to the CHANGELOG.md file.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant