sudoconf / 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

PHPSQLParser cannot parse insert into ... select ... correctly #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
$parser = new PHPSQLParser("INSERT INTO newTablename (SELECT field1, field2, 
field3 FROM oldTablename where field1 > 100);", true);

What is the expected output? What do you see instead?
We would expect to have INSERT, SELECT, FROM separated, instead we get:
    [INSERT] => Array
        (
            [table] => newTablename
            [columns] => Array
                (
                    [0] => Array
                        (
                            [expr_type] => colref
                            [base_expr] => SELECT field1
                            [position] => 26
                        )

                    [1] => Array
                        (
                            [expr_type] => colref
                            [base_expr] => field2
                            [position] => 41
                        )

                    [2] => Array
                        (
                            [expr_type] => colref
                            [base_expr] => field3 FROM oldTablename where field1 > 100
                            [position] => 49
                        )

                )

            [base_expr] => newTablename
            [position] => 12
        )

What version of the product are you using? On what operating system?
current (22.08.2012)

Please provide any additional information below.
This issue may have a dependency with #83 or vice versa

Original issue reported on code.google.com by i...@enterprise-technologies.de on 13 Dec 2012 at 8:08

GoogleCodeExporter commented 9 years ago
Hi.  Maybe this is because you are enclosing the select in parenthesis.

please try:
$parser = new PHPSQLParser("INSERT INTO newTablename SELECT field1, field2, 
field3 FROM oldTablename where field1 > 100;", true);

Original comment by greenlion@gmail.com on 13 Dec 2012 at 8:31

GoogleCodeExporter commented 9 years ago
Although I think, parenthesis should be accepted/parsed, you are right and it 
works fine without parenthesis.

For me that is now o.k. and solved, I can change our sql to adapt for 
php-sql-parser.

Thanks!

Original comment by i...@enterprise-technologies.de on 14 Dec 2012 at 5:49

GoogleCodeExporter commented 9 years ago
The revision r1004 contains code to fix this issue.

Original comment by pho...@gmx.de on 13 Jan 2014 at 10:10