Skip to content

Support MySQL index column length prefix syntax in CREATE TABLE UNIQUE constraint - #2536

Draft
mathiasrw with Copilot wants to merge 1 commit into
developfrom
copilot/fix-parse-error-create-table-unique
Draft

Support MySQL index column length prefix syntax in CREATE TABLE UNIQUE constraint#2536
mathiasrw with Copilot wants to merge 1 commit into
developfrom
copilot/fix-parse-error-create-table-unique

Conversation

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

AlaSQL fails to parse MySQL's index length prefix syntax (col(N)) inside UNIQUE constraints in CREATE TABLE statements, throwing a parse error at the LPAR token.

Changes

  • Grammar (src/alasqlparser.jison): Introduce an IndexColumnsList rule that accepts both plain column names (Literal) and column names with an optional length prefix (Literal LPAR Number RPAR). Update UniqueKey to use IndexColumnsList instead of OrderExpressionsList.
  • Parser (src/alasqlparser.js): Regenerated from updated .jison grammar via yarn jison.
  • Tests (test/test406.js): Added regression tests covering single column with length prefix, multiple columns with length prefixes, and mixed columns (with and without prefix).

Example

-- Previously threw: Parse error ... got 'LPAR'
CREATE TABLE t7(a TEXT, UNIQUE (a(1)));

-- Multiple columns with length prefixes
CREATE TABLE t8(a TEXT, b TEXT, UNIQUE (a(1), b(2)));

-- Mixed: length-prefixed and plain columns
CREATE TABLE t9(a TEXT, b INT, UNIQUE (a(5), b));

Copilot AI linked an issue Aug 25, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix parse error in CREATE TABLE UNIQUE statement Support MySQL index column length prefix syntax in CREATE TABLE UNIQUE constraint Aug 25, 2026
Copilot AI requested a review from mathiasrw August 25, 2026 17:30
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.

Parse error CREATE TABLE UNIQUE (a(1))

2 participants