Skip to content

Use MySQL tokenization for Polars input - #2495

Merged
rolandwalker merged 1 commit into
dbcli:mainfrom
pcbeingused33:fix/mycli-c9029
Dec 4, 2026
Merged

rolandwalker merged 1 commit into
dbcli:mainfrom
pcbeingused33:fix/mycli-c9029

Conversation

@pcbeingused33

Copy link
Copy Markdown
Contributor

Description

The interactive REPL checks each statement for Polars operators before sending
it to MySQL. The generic SQL tokenizer treats the backslash-escaped apostrophe
in a literal such as SELECT 'can\'t'; as a closing quote. This raises a Polars
parse error even when the statement has no transform.

Use SQLGlot's MySQL tokenizer when looking for Polars operators, matching the
dialect already used to validate the SQL before a transform. The REPL tests
verify that the original SQL reaches the executor with and without a transform
and that operators inside a quoted string are ignored. The two escaped-apostrophe
cases fail on main. All 718 REPL, Polars transform, and hybrid redirection tests
pass with the fix.

Ruff lint, Ruff formatting, and mypy checks pass for the changed Python files.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the mycli/AUTHORS.txt file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

This PR was prepared with AI assistance from Codex.

@rolandwalker

Copy link
Copy Markdown
Contributor

Nice catch!

@rolandwalker
rolandwalker merged commit fd7c96a into dbcli:main Dec 4, 2026
13 checks passed
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.

2 participants