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

parser dies when calculating position of "or column is null" #69

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 = "select * from table1 where col1<>col2 or col3 is null";
$parser->parse($sql, true);

2.
Script dies with:
PHP Fatal error:  Uncaught exception 'UnableToCalculatePositionException' with 
message 'cannot calculate position of null within  null;' in 
php-sql-parser.php:2026

What is the expected output? What do you see instead?
Expected the parser to return an array

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

Please provide any additional information below.

Original issue reported on code.google.com by marisr...@gmail.com on 9 Aug 2012 at 9:34

GoogleCodeExporter commented 8 years ago
Not a solution but a workaround if you are not using the positions is to call 
the parser with:

$parser->parse($sql);

Original comment by Marco6...@gmail.com on 11 Aug 2012 at 3:42

GoogleCodeExporter commented 8 years ago
The problem occurs, because "null" is set as operator, it should be set to 
constant. Let me look into the code...

Original comment by pho...@gmx.de on 16 Aug 2012 at 9:24

GoogleCodeExporter commented 8 years ago
Check out REV 299, it should work now. Plz check your client code, the NULL 
keyword is no longer an "operator", it is now a "constant".

Original comment by pho...@gmx.de on 16 Aug 2012 at 9:46

GoogleCodeExporter commented 8 years ago
I tested the original query with REV 300 and it works as expected.

Thank you.

Original comment by marisr...@gmail.com on 17 Aug 2012 at 7:56

GoogleCodeExporter commented 8 years ago

Original comment by pho...@gmx.de on 17 Aug 2012 at 9:01