spamspam252 / php-sql-parser

Automatically exported from code.google.com/p/php-sql-parser
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Missing commas in reference builder #144

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Parse and recreate the following query:
SELECT * FROM TableA JOIN TableB USING(Col1, Col2)

The creator returns
SELECT * FROM TableA INNER JOIN TableB USING (Col1 Col2)
, which is not valid SQL.

I fixed the problem by changing RefClauseBuilder.php.
line 87 is now: $sql .= ", ";
line 89 is now: return "(" . substr($sql, 0, -2) . ")";

Original issue reported on code.google.com by kitts...@gmail.com on 2 Jul 2014 at 10:28

GoogleCodeExporter commented 8 years ago
Upon further exploration, this is not a robust fix, as it can break some other 
type of reference clauses (specifically ON clauses).

I am using the version added 2014-01-08.

Original comment by kitts...@gmail.com on 2 Jul 2014 at 11:24

GoogleCodeExporter commented 8 years ago
It is better to enhance the parser first. After USING follows a column list and 
not only a bracket_expression. This will give the builder a chance to create 
different things.

Original comment by pho...@gmx.de on 11 Sep 2014 at 8:00

GoogleCodeExporter commented 8 years ago
Please try r1380, it contains some changes to fix the issue.

Original comment by pho...@gmx.de on 11 Sep 2014 at 9:30

GoogleCodeExporter commented 8 years ago

Original comment by pho...@gmx.de on 15 Sep 2014 at 7:01