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

PHPSQLCreator doesn't seem to support /*comment*/ "unknown [expr_type] = comment in "WHERE" [x]" #367

Open ParleyHammon opened 1 year ago

ParleyHammon commented 1 year ago

I have version v4.5.0

When I create a WHERE statement like WHERE s.status_id != 8 /*Pending*/ parse it then try to create it from the parse I get "unknown [expr_type] = comment in "WHERE" [x]"

The Parser seems to understand it: [{"expr_type":"comment","value":"\/*Pending*\/"}]

PHPSQLCreator just needs to add it back in

ParleyHammon commented 1 year ago

What's even more interesting is PHPSQLParser mistook a comment like "# Set" as a colref {"expr_type":"colref","base_expr":"# Set","no_quotes":{"delim":false,"parts":["# Set"]},"sub_tree":false} So PHPSQLCreator added it back in and because PHPSQLCreator generates the query in one line it commented out the rest of the query.