Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.7.0

Bug #14744 keyword parse problem
Submitted: 2008-10-05 11:18 UTC
From: paruwo Assigned: doconnor
Status: Closed Package: SQL_Parser (version 0.5)
PHP Version: Irrelevant OS: Windows XP
Roadmaps: (Not assigned)    
Subscription  


 [2008-10-05 11:18 UTC] paruwo (Christian Eberhardt)
Description: ------------ Fields that are named like key words like "count" or "values" are not properly parsed. As a workaround I rename those fields to a non-keyword name before parsing. Test script: --------------- $struct = $parser->parse("select value from sessions"); echo $struct['table_names'][0]; $struct = $parser->parse("select count from sessions"); echo $struct['table_names'][0]; Expected result: ---------------- Fatal error: Cannot use object of type PEAR_Error as array in <my_php_file> line <line_number>

Comments

 [2008-10-05 17:18 UTC] doconnor (Daniel O'Connor)
Christian, stupid question from someone not familiar with the package, but wouldn't you expect it to generate an error on sql keywords that aren't escaped? IE: select value from sessions # fail select `value` from sessions # ok
 [2008-10-09 12:38 UTC] doconnor (Daniel O'Connor)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. From CVS; this works: <?php require_once 'SQL/Parser.php'; function assertFieldName($data, $expected_field) { assert($data['select_expressions'][0]['args'][0] == $expected_field); } $parser = new SQL_Parser(); list($data) = $parser->parse("select value from sessions"); assertFieldName($data, 'value'); list($data) = $parser->parse("select count from sessions"); assertFieldName($data, 'count');