Skip to content

fix: parse doubled single quote in quoted type strings - #608

Open
pcbeingused333 wants to merge 1 commit into
ClickHouse:masterfrom
pcbeingused333:fix/enum-doubled-single-quote
Open

pcbeingused333 wants to merge 1 commit into
ClickHouse:masterfrom
pcbeingused333:fix/enum-doubled-single-quote

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #605

Cause. In TypeParser::NextToken, the single-quote branch closes the string at the first ' it sees, without checking whether the next character is another '. CreateColumnByType("Enum8('it''s' = 1)") therefore split 'it''s' into two tokens, and the second one overwrote the label: the type was accepted with no error as Enum8('s' = 1), so Append("it's") later threw unknown enum name. The " and ` branch directly below already handles the doubled-quote form.

Fix. Treat '' inside a single-quoted string as an escaped single quote. Other escapes are untouched.

Test. TypeParserCase.ParseEnum_DoubledSingleQuote covers 'it''s' and '''a'''; it fails on main and passes with the change (43/43 TypeParser* tests).

This change was prepared with the assistance of an AI coding tool (Claude) and submitted by the account owner.


Note

Low Risk
Localized lexer fix in type parsing with targeted unit tests; no auth, data, or API surface changes beyond correct string decoding.

Overview
Fixes incorrect tokenization of single-quoted literals in ClickHouse type strings when a label contains an apostrophe written as '' (ClickHouse-style escape).

TypeParser::NextToken previously ended the quoted string on the first ', so types like Enum8('it''s' = 1) were parsed with the wrong enum name (e.g. 's'), breaking inserts that use the real label. The parser now treats consecutive '' inside single-quoted strings as one escaped ', matching the existing behavior for " and backtick-quoted identifiers.

A unit test covers enum parsing for 'it''s' and the edge case '''a''' → 'a'.

Reviewed by Cursor Bugbot for commit 1126c72. Bugbot is set up for automated code reviews on this repo. Configure here.

Enum8('it''s' = 1) was cut at the first quote of the pair, so the enum
label was truncated. Treat '' as an escaped single quote, as the
double-quote and backtick branches already do for their own quote.
@github-actions

Copy link
Copy Markdown

AI review gate — AI review gate could not decide

  • ai-gate: could not list pull requests for 1126c72 — gh api repos/ClickHouse/clickhouse-cpp/commits/1126c72b99d37abebba68fc983f3e9ad1e3c8dea/pulls failed: unexpected end of JSON input

What to do:

  • This is a GitHub API or permissions problem, not your change. Re-run the gate; if it keeps failing, ask a repository administrator.

Re-run the gate with “Re-run jobs” after an approval or a finished review. A push re-runs it automatically.

@slabko

slabko commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Note: server never returns Enum8('it''s' = 1) - no matter how column is created, it will be converted to Enum8('it\'s' = 1) by the server.

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.

Type parser: SQL doubled single quote in an Enum label is silently mis-parsed (Enum8('it''s' = 1) becomes Enum8('s' = 1))

2 participants