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

Bug #4034 Assignment of field = field not recognized
Submitted: 2005-04-03 04:29 UTC
From: epte at ruffdogs dot com Assigned: busterb
Status: Closed Package: SQL_Parser
PHP Version: 4.3.8 OS: Linux/Gentoo
Roadmaps: (Not assigned)    
Subscription  


 [2005-04-03 04:29 UTC] epte at ruffdogs dot com
Description: ------------ The following code breaks. Apparently it's expecting a value, and not to be set to the value of some other database field. Reproduce code: --------------- $sql = ' UPDATE tblTicklerPatientData SET tblTicklerPatientData.final_diagnosis = ptc.path_diagnosis_codes FROM tblTicklerPatientData INNER JOIN `PatientTest(Case)` as ptc ON tblTicklerPatientData.PatientTest_key = ptc.PatientTest_key WHERE ptc.path_diagnosis_codes Is Not Null and tblTicklerPatientData.final_diagnosis is null'; $_SQLParser = new SQL_Parser(NULL, 'MySQL'); $parseRes = $_SQLParser->parse($sql); Actual result: -------------- The error: Expected a value on line 3 SET tblTicklerPatientData.final_diagnosis = ptc.path_diagnosis_codes ^ found: "ptc.path_diagnosis_codes"

Comments

 [2005-04-03 04:37 UTC] epte at ruffdogs dot com
Fixed it. Patch follows (the second hunk is the fix). Leaving open so the patch can be seen and submitted. --- Parser.php 3 Jul 2004 04:49:44 -0000 1.27 +++ Parser.php 3 Apr 2005 04:34:07 -0000 @@ -143,6 +143,7 @@ // {{{ isVal() function isVal() { return (($this->token == 'real_val') || + ($this->token == 'function') || ($this->token == 'int_val') || ($this->token == 'text_val') || ($this->token == 'null')); @@ -766,8 +767,8 @@ return $this->raiseError('Expected ='); } $this->getTok(); - if (!$this->isVal($this->token)) { - return $this->raiseError('Expected a value'); + if (!$this->isVal($this->token) && $this->token != 'ident') { + return $this->raiseError('Expected a value or column name'); } $tree['values'][] = array('value'=>$this->lexer->tokText, 'type'=>$this->token);
 [2005-04-06 04:55 UTC] busterb
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. Thanks for the patch!