PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » SQL_Parser » Bug #4034

Assignment of field = field not recognized

Details

Submitted2005-04-03 04:29 UTC
Fromepte at ruffdogs dot com
Assignedbusterb
StatusClosed
PackageSQL_Parser
PHP Version4.3.8
OSLinux/Gentoo
Roadmaps(Not assigned)

Comments

[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"

[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);