sqlparser
sqlparser copied to clipboard
unexpected error parsing DDL using FOREIGN KEY
when usingsqlparser.ParseStrictDDL
I receive an error
syntax error at position 290 near 'foreign'
when parsing valid mySQL:
CREATE TABLE `comments` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`content` TEXT DEFAULT NULL,
`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_edited` TIMESTAMP,
`user_id` VARCHAR(18) NOT NULL,
`post_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`post_id`) REFERENCES posts(id) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
I expected that foreign key would be parseable?
Parsing of DDL is incomplete, so with Strict there will be issues. I'll keep this open to track improving the parsing.