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

Valid query is parsed and re-created as invalid query (too many comma in group_concat) #353

Closed sadjehwty closed 2 years ago

sadjehwty commented 2 years ago

The below code example attempts to parse a valid SQL query and re-create it. $this->creator and $this->parser are instances of the creator and parser.

Upon the query being re-created, the argument of the group_concat is splitted in three arguments, causing an SQL error.

var_dump(
  $this->creator->create(
    $this->parser->parse(
      "SELECT student_name,
         GROUP_CONCAT(DISTINCT test_score
                      ORDER BY test_score DESC SEPARATOR ' ')
       FROM student
       GROUP BY student_name;"
    )
  )
);
exit;

Tested with v4.5.0