vikramkakar / 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 expr_type for variables #72

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. execute this code :

$parser = new PHPSQLParser();
$sql = "update table set column=@max;";
$parser->parse($sql);

2. In the returned array, "@" is identified as "colref" and "max" as an 
"aggregate_function":
...
                            [2] => Array
                                (
                                    [expr_type] => colref
                                    [base_expr] => @
                                    [sub_tree] => 
                                )

                            [3] => Array
                                (
                                    [expr_type] => aggregate_function
                                    [base_expr] => max
                                    [sub_tree] => 
...

What is the expected output? What do you see instead?
...
                            [2] => Array
                                (
                                    [expr_type] => user_defined_variable
                                    [base_expr] => @max
                                    [sub_tree] => 
                                )
...

What version of the product are you using? On what operating system?
r303, Ubuntu 12.04

Please provide any additional information below.
If the variable name is not a keyword, it is identified as a colref:
...
                            [2] => Array
                                (
                                    [expr_type] => colref
                                    [base_expr] => @
                                    [sub_tree] => 
                                )

                            [3] => Array
                                (
                                    [expr_type] => colref
                                    [base_expr] => not_keyword
                                    [sub_tree] => 
                                )
...

Original issue reported on code.google.com by marisr...@gmail.com on 20 Aug 2012 at 7:27

GoogleCodeExporter commented 8 years ago
That is the same problem as issue 67.

Original comment by pho...@gmx.de on 20 Aug 2012 at 7:59

GoogleCodeExporter commented 8 years ago
Check out r308, it solves the problem. Is it ok to set user_variable instead of 
user_defined_variable?

Original comment by pho...@gmx.de on 20 Aug 2012 at 10:12

GoogleCodeExporter commented 8 years ago
Either name it's OK.

I took the name from mysql docs title "9.4. User-Defined Variables", but if you 
look at it's content both versions are use for the same purpose.

Original comment by marisr...@gmail.com on 20 Aug 2012 at 10:20