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
604 stars 156 forks source link

"WITH" clause with comments, temporary table name is wrong. #374

Open rkamite opened 1 year ago

rkamite commented 1 year ago

I have version v4.4.0

Here is a SQL having "WITH" clause with comments.

with
-- comment for temporary table
TEMP_TABLE_NAME as (select ... )

temporary table should ber TEMP_TABLE_NAME but -- comment for temporary table.

"WITH" clause is tokenized as below

Currently, the first token is always interpreted as a temporary table name. "the first token excluded comments" should be interpreted as a temporary table name.