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

Bug #8388 PATCH NEEDED - Between statements not recognized
Submitted: 2006-08-08 13:43 UTC
From: denis at denismayer dot com Assigned:
Status: Open Package: SQL_Parser (version CVS)
PHP Version: 5.1.4 OS: Windows
Roadmaps: 0.5.1    
Subscription  


 [2006-08-08 13:43 UTC] denis at denismayer dot com (Denis)
Description: ------------ The following sql statement is not recognized by the SQL Parser: SELECT AVG(CUSTOMER.AGE) FROM CUSTOMER WHERE CUSTOMER.AGE BETWEEN 21 AND 35 GROUP BY CUSTOMER.AGE The parser says that GROUP token is not an operator. I believe the parser is not recognizing the BETWEEN statement properly.

Comments

 [2006-08-25 07:36 UTC] home at saint dot vel dot pl (Chris)
I encountered the same problem and I think the problem is that between operator does not have special treatment in the SQL_Parser::parseSearchClause() function, i.e. and is interpreted as the begining of the next constraint in the where clause while it should be a part of the current expression. I think the solution is easy. When you add a short block of code in the previously mentioned function it is working fine. In switch(clause['op']) statement add new case block like that: case 'between': if ($this->isReserved()) { return $this->raiseError('Expected a value'); } $clause['arg_2']['value'] = $this->lexer->tokText; $clause['arg_2']['type'] = $this->token; //if next token is not and then raise error $this->getTok(); if ($this->token != 'and') { return $this->raiseError('Expected "and"'); } //get next token $this->getTok(); if ($this->isReserved()) { return $this->raiseError('Expected a value'); } $clause['arg_3']['value'] = $this->lexer->tokText; $clause['arg_3']['type'] = $this->token; break;
 [2007-06-28 11:13 UTC] cybot (Sebastian Mendel)
to fully fix this a design change is required BETWEEN (like most expression) is not only valid in SQL-Codeblock handled currently by parseSearchClause() but could also f.e. in "SELECT 2 BETWEEN 1 AND 3"
 [2011-02-14 10:13 UTC] alan_k (Alan Knowles)
-Summary: Between statements not recognized +Summary: PATCH NEEDED - Between statements not recognized