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

incorrect parsing output if an aliased string contains a single quote escaped with a backslash #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. execute the following code :

$sql = "SELECT 'a string with an escaped quote \' in it' AS some_alias FROM 
some_table";
echo $sql . "\n";
$parser = new PHPSQLParser($sql, true);
print_r($parser->parsed);

What is the expected output? What do you see instead?

expected output : a SELECT and a FROM index in the parsed array.

instead : only a SELECT, and the base_expr is incorrect (contains the FROM 
keyword and the end of the query)

Array
(
    [SELECT] => Array
        (
            [0] => Array
                (
                    [expr_type] => const
                    [alias] =>
                    [base_expr] => 'a string with an escaped quote \' in it' AS some_alias FROM some_table
                    [sub_tree] =>
                    [position] => 7
                )
        )
)

What version of the product are you using? On what operating system?

rev 235, on windows 7.

Original issue reported on code.google.com by nderm...@adequasys.com on 20 Apr 2012 at 1:46

GoogleCodeExporter commented 9 years ago
Can you check the REV 239? I have added a test case.

Original comment by pho...@gmx.de on 26 Apr 2012 at 11:37

GoogleCodeExporter commented 9 years ago

Original comment by pho...@gmx.de on 30 Apr 2012 at 11:26