PHP-SQL-Parser icon indicating copy to clipboard operation
PHP-SQL-Parser copied to clipboard

may not parse create table with index

Open qiukeren opened this issue 7 years ago • 3 comments

CREATE TABLE `MDBAuthConfig` (
 `id` int(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
 `a` int(10) unsigned NOT NULL COMMENT 'a',
 `b` varchar(64) NOT NULL DEFAULT '' COMMENT 'b',
 `c` int(10) unsigned NOT NULL COMMENT 'c',
 `d` varchar(64) NOT NULL DEFAULT '' COMMENT 'd',
 `e` varchar(255) NOT NULL COMMENT 'e',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'a',
 `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'aa',
 `deleted_at` timestamp NULL DEFAULT NULL,
 PRIMARY KEY (`id`),
 KEY `idx_a_b_c` (`a`,`b`,`c`)
) ENGINE=InnoDB AUTO_INCREMENT=901 DEFAULT CHARSET=utf8 COMMENT='ttt'

errors with cannot calculate position of `a`, within (`a`,`b`,`c`) ) ENGINE=InnoDB AUTO_INCREMENT=901 DEFAULT CHARSET=utf8 COMMENT='ttt'

however it works well without KEY `idx_a_b_c` (`a`,`b`,`c`)

qiukeren avatar Dec 22 '16 07:12 qiukeren

same exception as #226

UnableToCalculatePositionException at PositionCalculator.php line 243

qiukeren avatar Dec 22 '16 07:12 qiukeren

@qiukeren the issue is the lack of a space after the commas in the KEY definition, ie.

KEY `idx_a_b_c` (`a`, `b`, `c`)

works - however, the parsed output of this statement fails to be created correctly - see https://github.com/greenlion/PHP-SQL-Parser/issues/22.

polevaultweb avatar Mar 01 '17 09:03 polevaultweb

Did anyone solve this by any chance? Didn't get a chance to deep dive into this issue, as disabling the position calculator was a good enough workaround for me (as I'm not using the position value). Will update here in case I'll have more information.

tomershay avatar Jun 18 '17 18:06 tomershay