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

join with to_number in on clause #157

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have tables you can't change that incorrectly store numbers as strings
2. join those tables using the 'to_number' function in the on clause
3. parse sql

What is the expected output? What do you see instead?
I would expect the library to detect the function and column, or at the very 
least ignore the function and detect the columns being joined on. The error and 
slq are posted below.

What version of the product are you using? On what operating system?
This problem exists in version 20140108. We are using Ubuntu 9.04 ( yes they 
haven't updated us yet... ). I can test this on debian 7 from home if needed.

Please provide any additional information below.

SQL:
SELECT *
FROM SC_CATALOG_DETAIL_REG CD
INNER JOIN MASTER_ITEM_LOOKUP IL
ON to_number( CD.STYLE ) = to_number( IL.SKU_NUM )

ERROR:
Fatal error:  Uncaught exception 'UnableToCalculatePositionException' with 
message 'cannot calculate position of MASTER_ITEM_LOOKUP IL
  ON to_number( CD.STYLE ) = to_number( IL.SKU_NUM ) within  )' in /var/www/test_dir/PHP-SQL-Parser/src/positions/PositionCalculator.php:199
Stack trace:
#0 /var/www/test_dir/PHP-SQL-Parser/src/positions/PositionCalculator.php(215): 
PositionCalculator->lookForBaseExpression('SELECT *?  FROM...', 126, Array, 1, 
Array)
#1 /var/www/test_dir/PHP-SQL-Parser/src/positions/PositionCalculator.php(215): 
PositionCalculator->lookForBaseExpression('SELECT *?  FROM...', 126, Array, 
'FROM', Array)
#2 /var/www/test_dir/PHP-SQL-Parser/src/positions/PositionCalculator.php(70): 
PositionCalculator->lookForBaseExpression('SELECT *?  FROM...', 126, Array, 0, 
Array)
#3 /var/www/test_dir/PHP-SQL-Parser/src/PHPSQLParser.php(90): 
PositionCalculator->setPositionsWithinSQL('SELECT *?  FROM...', Array)
#4 /var/www/test_dir/PHP-SQL-Parser/src/PHPSQLParser.php(65): 
PHPSQLParser->parse('SELECT *?  FROM...', true)
#5 /var in 
/var/www/test_dir/PHP-SQL-Parser/src/positions/PositionCalculator.php on line 
199

Original issue reported on code.google.com by NBakerCa...@gmail.com on 23 Dec 2014 at 3:42

GoogleCodeExporter commented 9 years ago
I did leave out that this is being used within oracle. I did overlook that this 
is geared towards mysql.

Original comment by NBakerCa...@gmail.com on 23 Dec 2014 at 5:11