greenlion / PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL
BSD 3-Clause "New" or "Revised" License
601 stars 156 forks source link

CHARACTER keyword as alias of CHAR type spoils parsing CHARACTER SET utf8 #365

Open czoIg opened 2 years ago

czoIg commented 2 years ago

Added in #355 support for CHARACTER as alias of CHAR data type spoils parsing of CHARACTER SET utf8:

CREATE TABLE IF NOT EXISTS example (`type` varchar (255) CHARACTER SET utf8 NOT NULL) DEFAULT CHARACTER SET utf8

which ends up with skipping the encoding in created query and breaks the Issue265Test:

-'CREATE TABLE IF NOT EXISTS example (`type` varchar (255) CHARACTER SET NOT NULL) DEFAULT CHARACTER SET utf8'
+'CREATE TABLE IF NOT EXISTS example (`type` varchar (255) CHARACTER SET utf8 NOT NULL) DEFAULT CHARACTER SET utf8'

I propose to remove the CHARACTER as it is very rare and undocumented.