Skip to content

Support CHARACTER and double-quoted identifiers - #36

Open
sebj54 wants to merge 2 commits into
iamcal:masterfrom
sebj54:support-character-and-quoted-identifiers
Open

sebj54 wants to merge 2 commits into
iamcal:masterfrom
sebj54:support-character-and-quoted-identifiers

Conversation

@sebj54

@sebj54 sebj54 commented Nov 20, 2026

Copy link
Copy Markdown

Two small fixes for syntax that MySQL accepts and that is also common in dumps from other databases (PostgreSQL's pg_dump writes both).

Support CHARACTER as a synonym of CHAR

CHARACTER[(length)] is a synonym of CHAR in MySQL, but the parser rejects it:

CREATE TABLE t (a CHARACTER(36) NOT NULL)
=> SQLParserSyntaxException: Unsupported field type: CHARACTER

It is now parsed like CHAR (the reported type stays CHARACTER, like CHARACTER VARYING), so the length, NULL and the other options are read.

Accept double-quoted identifiers

With the ANSI_QUOTES SQL mode, and in standard SQL, "name" is a delimited identifier. The tokenizer already keeps "..." as one token, but decode_identifier() only strips backticks, so the quotes end up in the names:

CREATE TABLE public."references" ("id" INT)
=> table name: "references" (with the quotes), field name: "id" (with the quotes)

decode_identifier() now strips the quotes and turns "" back into ". It is only used where an identifier is expected, so string literals are not affected.

Tests

Added a CHARACTER(36) NOT NULL case to testChars and a testDoubleQuotedIdentifiers test (schema-qualified table, plain and escaped field names). The suite otherwise behaves as before: FullTest reports "No tests found" on my PHPUnit 11 setup, with or without these changes.

🤖 Generated with Claude Code

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