Skip to content

Parsing failure CREATE TABLE with order in INDEX #308

@Gared

Description

@Gared

Hey this parser is very cool and searched forever until I found it :-)
I just have a problem parsing my scheme definition when I have a CREATE TABLE query with an INDEX in it:

CREATE TABLE test (
  user_id INT,
  INDEX `test` (user_id ASC),
)

This gets parsed as the following definition:

object(PhpMyAdmin\SqlParser\Components\CreateDefinition)#2102 (6) {
  ["name"]=>
  NULL
  ["isConstraint"]=>
  NULL
  ["type"]=>
  NULL
  ["key"]=>
  object(PhpMyAdmin\SqlParser\Components\Key)#2103 (4) {
    ["name"]=>
    string(4) "test"
    ["columns"]=>
    array(1) {
      [0]=>
      array(1) {
        ["name"]=>
        string(3) "ASC"
      }
    }
    ["type"]=>
    string(5) "INDEX"
    ["options"]=>
    object(PhpMyAdmin\SqlParser\Components\OptionsArray)#2104 (1) {
      ["options"]=>
      array(0) {
      }
    }
  }
  ["references"]=>
  NULL
  ["options"]=>
  NULL
}

The problem is in $object->key->columns I have an array with "ASC" in it, but this should be "user_id" (the name of the column - not the order).
If I remove the order ("ASC") the parsing works as expected.

Tested it with the latest version (5.3.1)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions