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

Fix confusion between CHARACTER data type and CHARACTER SET issue #376

Closed xsist10 closed 8 months ago

xsist10 commented 9 months ago

Confusion between CHARACTER type and CHARACTER SET

In an attempt to fix the data type aliases per https://github.com/greenlion/PHP-SQL-Parser/issues/355, I introduced a bug documented in https://github.com/greenlion/PHP-SQL-Parser/issues/365.

This change separates out the CHARACTER check to do a look ahead to see if the next keyword is `SET and splits the logic appropriately.

An alternative would be to look back at the constructed expression array ($expr) to see if a ExpressionType::DATA_TYPE has already been defined.

Additionally this also includes a fix to support CHARSET which is a valid alias for CHARACTER SET per the MySQL character sets documentation.

This is an alternative to the fix proposed by https://github.com/greenlion/PHP-SQL-Parser/pull/366