Commit 55bb4055 authored by jepso's avatar jepso

- Replaced NUMERIC token with INTEGER and FLOAT tokens

- LIMIT and OFFSET clauses allow only integers now
- Added support for INDEX BY
- Added more tests, fixed failing tests, etc.
parent 733eecbb
<?php <?php
class Doctrine_Query_Parser_Exception extends Exception /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Query_Parser_Exception
*
* @package Doctrine
* @subpackage Query
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @version $Revision$
*/
class Doctrine_Query_Parser_Exception extends Doctrine_Exception
{ {
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
/** /**
* Atom = string | numeric | input_parameter * Atom = string | integer | float | input_parameter
* *
* @package Doctrine * @package Doctrine
* @subpackage Query * @subpackage Query
...@@ -38,8 +38,11 @@ class Doctrine_Query_Production_Atom extends Doctrine_Query_Production ...@@ -38,8 +38,11 @@ class Doctrine_Query_Production_Atom extends Doctrine_Query_Production
case Doctrine_Query_Token::T_STRING: case Doctrine_Query_Token::T_STRING:
$this->_parser->match(Doctrine_Query_Token::T_STRING); $this->_parser->match(Doctrine_Query_Token::T_STRING);
break; break;
case Doctrine_Query_Token::T_NUMERIC: case Doctrine_Query_Token::T_INTEGER:
$this->_parser->match(Doctrine_Query_Token::T_NUMERIC); $this->_parser->match(Doctrine_Query_Token::T_INTEGER);
break;
case Doctrine_Query_Token::T_FLOAT:
$this->_parser->match(Doctrine_Query_Token::T_FLOAT);
break; break;
case Doctrine_Query_Token::T_INPUT_PARAMETER: case Doctrine_Query_Token::T_INPUT_PARAMETER:
$this->_parser->match(Doctrine_Query_Token::T_INPUT_PARAMETER); $this->_parser->match(Doctrine_Query_Token::T_INPUT_PARAMETER);
......
...@@ -43,8 +43,8 @@ class Doctrine_Query_Production_ComparisonExpression extends Doctrine_Query_Prod ...@@ -43,8 +43,8 @@ class Doctrine_Query_Production_ComparisonExpression extends Doctrine_Query_Prod
} else { } else {
switch ($this->_parser->lookahead['type']) { switch ($this->_parser->lookahead['type']) {
case Doctrine_Query_Token::T_ALL: case Doctrine_Query_Token::T_ALL:
case Doctrine_Query_Token::T_ANY:
case Doctrine_Query_Token::T_SOME: case Doctrine_Query_Token::T_SOME:
case Doctrine_Query_Token::T_NONE:
$this->QuantifiedExpression(); $this->QuantifiedExpression();
break; break;
default: default:
......
...@@ -36,11 +36,19 @@ class Doctrine_Query_Production_IdentificationVariableDeclaration extends Doctri ...@@ -36,11 +36,19 @@ class Doctrine_Query_Production_IdentificationVariableDeclaration extends Doctri
{ {
$rangeVarDecl = $this->RangeVariableDeclaration(); $rangeVarDecl = $this->RangeVariableDeclaration();
if ($this->_isNextToken(Doctrine_Query_Token::T_INDEX)) {
$this->IndexBy();
}
while ($this->_isNextToken(Doctrine_Query_Token::T_LEFT) || while ($this->_isNextToken(Doctrine_Query_Token::T_LEFT) ||
$this->_isNextToken(Doctrine_Query_Token::T_INNER) || $this->_isNextToken(Doctrine_Query_Token::T_INNER) ||
$this->_isNextToken(Doctrine_Query_Token::T_JOIN)) { $this->_isNextToken(Doctrine_Query_Token::T_JOIN)) {
$this->Join(); $this->Join();
if ($this->_isNextToken(Doctrine_Query_Token::T_INDEX)) {
$this->IndexBy();
}
} }
} }
} }
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* IndexBy = "INDEX" "BY" PathExpression
*
* @package Doctrine
* @subpackage Query
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @version $Revision$
*/
class Doctrine_Query_Production_IndexBy extends Doctrine_Query_Production
{
public function execute(array $params = array())
{
$this->_parser->match(Doctrine_Query_Token::T_INDEX);
$this->_parser->match(Doctrine_Query_Token::T_BY);
$this->PathExpression();
}
}
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
/** /**
* Join = ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression] [IndexBy] * Join = ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression]
* *
* @package Doctrine * @package Doctrine
* @subpackage Query * @subpackage Query
...@@ -51,9 +51,5 @@ class Doctrine_Query_Production_Join extends Doctrine_Query_Production ...@@ -51,9 +51,5 @@ class Doctrine_Query_Production_Join extends Doctrine_Query_Production
$this->_parser->match(Doctrine_Query_Token::T_WITH); $this->_parser->match(Doctrine_Query_Token::T_WITH);
$this->ConditionalExpression(); $this->ConditionalExpression();
} }
if ($this->_isNextToken(Doctrine_Query_Token::T_INDEX)) {
$this->IndexBy();
}
} }
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
/** /**
* LimitClause = "LIMIT" Expression * LimitClause = "LIMIT" integer
* *
* @package Doctrine * @package Doctrine
* @subpackage Query * @subpackage Query
...@@ -35,6 +35,6 @@ class Doctrine_Query_Production_LimitClause extends Doctrine_Query_Production ...@@ -35,6 +35,6 @@ class Doctrine_Query_Production_LimitClause extends Doctrine_Query_Production
public function execute(array $params = array()) public function execute(array $params = array())
{ {
$this->_parser->match(Doctrine_Query_Token::T_LIMIT); $this->_parser->match(Doctrine_Query_Token::T_LIMIT);
$this->Expression(); $this->_parser->match(Doctrine_Query_Token::T_INTEGER);
} }
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
/** /**
* OffsetClause = "OFFSET" Expression * OffsetClause = "OFFSET" integer
* *
* @package Doctrine * @package Doctrine
* @subpackage Query * @subpackage Query
...@@ -35,6 +35,6 @@ class Doctrine_Query_Production_OffsetClause extends Doctrine_Query_Production ...@@ -35,6 +35,6 @@ class Doctrine_Query_Production_OffsetClause extends Doctrine_Query_Production
public function execute(array $params = array()) public function execute(array $params = array())
{ {
$this->_parser->match(Doctrine_Query_Token::T_OFFSET); $this->_parser->match(Doctrine_Query_Token::T_OFFSET);
$this->Expression(); $this->_parser->match(Doctrine_Query_Token::T_INTEGER);
} }
} }
...@@ -44,7 +44,8 @@ class Doctrine_Query_Production_Primary extends Doctrine_Query_Production ...@@ -44,7 +44,8 @@ class Doctrine_Query_Production_Primary extends Doctrine_Query_Production
} }
break; break;
case Doctrine_Query_Token::T_STRING: case Doctrine_Query_Token::T_STRING:
case Doctrine_Query_Token::T_NUMERIC: case Doctrine_Query_Token::T_INTEGER:
case Doctrine_Query_Token::T_FLOAT:
case Doctrine_Query_Token::T_INPUT_PARAMETER: case Doctrine_Query_Token::T_INPUT_PARAMETER:
$this->Atom(); $this->Atom();
break; break;
......
...@@ -70,7 +70,7 @@ class Doctrine_Query_Production_SimpleConditionalExpression extends Doctrine_Que ...@@ -70,7 +70,7 @@ class Doctrine_Query_Production_SimpleConditionalExpression extends Doctrine_Que
$this->ComparisonExpression(); $this->ComparisonExpression();
break; break;
default: default:
$this->_parser->syntaxError(); $this->_parser->logError();
} }
} }
......
...@@ -101,7 +101,11 @@ class Doctrine_Query_Scanner ...@@ -101,7 +101,11 @@ class Doctrine_Query_Scanner
$value = $match[0]; $value = $match[0];
if (is_numeric($value)) { if (is_numeric($value)) {
$type = Doctrine_Query_Token::T_NUMERIC; if (strpos($value, '.') !== false || stripos($value, 'e') !== false) {
$type = Doctrine_Query_Token::T_FLOAT;
} else {
$type = Doctrine_Query_Token::T_INTEGER;
}
} elseif ($value[0] === "'" && $value[strlen($value) - 1] === "'") { } elseif ($value[0] === "'" && $value[strlen($value) - 1] === "'") {
$type = Doctrine_Query_Token::T_STRING; $type = Doctrine_Query_Token::T_STRING;
} elseif (ctype_alpha($value[0]) || $value[0] === '_') { } elseif (ctype_alpha($value[0]) || $value[0] === '_') {
......
...@@ -34,9 +34,10 @@ final class Doctrine_Query_Token ...@@ -34,9 +34,10 @@ final class Doctrine_Query_Token
{ {
const T_NONE = 1; const T_NONE = 1;
const T_IDENTIFIER = 2; const T_IDENTIFIER = 2;
const T_NUMERIC = 3; const T_INTEGER = 3;
const T_STRING = 4; const T_STRING = 4;
const T_INPUT_PARAMETER = 5; const T_INPUT_PARAMETER = 5;
const T_FLOAT = 6;
const T_ALL = 101; const T_ALL = 101;
const T_AND = 102; const T_AND = 102;
...@@ -80,6 +81,8 @@ final class Doctrine_Query_Token ...@@ -80,6 +81,8 @@ final class Doctrine_Query_Token
const T_UPDATE = 140; const T_UPDATE = 140;
const T_WHERE = 141; const T_WHERE = 141;
const T_WITH = 142; const T_WITH = 142;
const T_TRUE = 143;
const T_FALSE = 144;
private function __construct() {} private function __construct() {}
} }
...@@ -26,18 +26,18 @@ FromClause = "FROM" IdentificationVariableDeclaration {"," IdentificationVa ...@@ -26,18 +26,18 @@ FromClause = "FROM" IdentificationVariableDeclaration {"," IdentificationVa
HavingClause = "HAVING" ConditionalExpression HavingClause = "HAVING" ConditionalExpression
GroupByClause = "GROUP" "BY" GroupByItem {"," GroupByItem} GroupByClause = "GROUP" "BY" GroupByItem {"," GroupByItem}
OrderByClause = "ORDER" "BY" OrderByItem {"," OrderByItem} OrderByClause = "ORDER" "BY" OrderByItem {"," OrderByItem}
LimitClause = "LIMIT" Expression LimitClause = "LIMIT" integer
OffsetClause = "OFFSET" Expression OffsetClause = "OFFSET" integer
UpdateClause = "UPDATE" RangeVariableDeclaration "SET" UpdateItem {"," UpdateItem} UpdateClause = "UPDATE" RangeVariableDeclaration "SET" UpdateItem {"," UpdateItem}
OrderByItem = Expression ["ASC" | "DESC"] OrderByItem = Expression ["ASC" | "DESC"]
GroupByItem = PathExpression GroupByItem = PathExpression
UpdateItem = PathExpression "=" (Expression | "NULL") UpdateItem = PathExpression "=" (Expression | "NULL")
IdentificationVariableDeclaration = RangeVariableDeclaration {Join} IdentificationVariableDeclaration = RangeVariableDeclaration [IndexBy] {Join [IndexBy]}
RangeVariableDeclaration = PathExpression [["AS"] IdentificationVariable] RangeVariableDeclaration = PathExpression [["AS"] IdentificationVariable]
Join = ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression] [IndexBy] Join = ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression]
IndexBy = "INDEX" "BY" PathExpression IndexBy = "INDEX" "BY" PathExpression
ConditionalExpression = ConditionalTerm {"OR" ConditionalTerm} ConditionalExpression = ConditionalTerm {"OR" ConditionalTerm}
...@@ -48,7 +48,7 @@ SimpleConditionalExpression ...@@ -48,7 +48,7 @@ SimpleConditionalExpression
= Expression (ComparisonExpression | BetweenExpression | LikeExpression = Expression (ComparisonExpression | BetweenExpression | LikeExpression
| InExpression | NullComparisonExpression) | ExistsExpression | InExpression | NullComparisonExpression) | ExistsExpression
Atom = string_literal | numeric_constant | input_parameter Atom = string | integer | float | boolean | input_parameter
Expression = Term {("+" | "-") Term} Expression = Term {("+" | "-") Term}
Term = Factor {("*" | "/") Factor} Term = Factor {("*" | "/") Factor}
...@@ -66,7 +66,7 @@ QuantifiedExpression = ("ALL" | "ANY" | "SOME") "(" Subselect ")" ...@@ -66,7 +66,7 @@ QuantifiedExpression = ("ALL" | "ANY" | "SOME") "(" Subselect ")"
BetweenExpression = ["NOT"] "BETWEEN" Expression "AND" Expression BetweenExpression = ["NOT"] "BETWEEN" Expression "AND" Expression
ComparisonExpression = ComparisonOperator ( QuantifiedExpression | Expression | "(" Subselect ")" ) ComparisonExpression = ComparisonOperator ( QuantifiedExpression | Expression | "(" Subselect ")" )
InExpression = ["NOT"] "IN" "(" (Atom {"," Atom} | Subselect) ")" InExpression = ["NOT"] "IN" "(" (Atom {"," Atom} | Subselect) ")"
LikeExpression = ["NOT"] "LIKE" Expression ["ESCAPE" string_literal] LikeExpression = ["NOT"] "LIKE" Expression ["ESCAPE" string]
NullComparisonExpression = "IS" ["NOT"] "NULL" NullComparisonExpression = "IS" ["NOT"] "NULL"
ExistsExpression = "EXISTS" "(" Subselect ")" ExistsExpression = "EXISTS" "(" Subselect ")"
......
...@@ -92,12 +92,12 @@ class Doctrine_Query_LanguageRecognition_TestCase extends Doctrine_UnitTestCase ...@@ -92,12 +92,12 @@ class Doctrine_Query_LanguageRecognition_TestCase extends Doctrine_UnitTestCase
public function testExistsExpressionSupportedInWherePart() public function testExistsExpressionSupportedInWherePart()
{ {
$this->assertValidDql('FROM User WHERE EXISTS (SELECT g.id FROM Groupuser g WHERE g.user_id = u.id)'); $this->assertValidDql('FROM User WHERE EXISTS (SELECT g.id FROM UserGroupuser g WHERE g.user_id = u.id)');
} }
public function testNotExistsExpressionSupportedInWherePart() public function testNotExistsExpressionSupportedInWherePart()
{ {
$this->assertValidDql('FROM User WHERE NOT EXISTS (SELECT g.id FROM Groupuser g WHERE g.user_id = u.id)'); $this->assertValidDql('FROM User WHERE NOT EXISTS (SELECT g.id FROM UserGroupuser g WHERE g.user_id = u.id)');
} }
public function testLiteralValueAsInOperatorOperandIsSupported() public function testLiteralValueAsInOperatorOperandIsSupported()
...@@ -183,42 +183,42 @@ class Doctrine_Query_LanguageRecognition_TestCase extends Doctrine_UnitTestCase ...@@ -183,42 +183,42 @@ class Doctrine_Query_LanguageRecognition_TestCase extends Doctrine_UnitTestCase
public function testLeftJoin() public function testLeftJoin()
{ {
$this->assertValidDql('FROM User u LEFT JOIN u.Group'); $this->assertValidDql('FROM User u LEFT JOIN u.UserGroup');
} }
public function testJoin() public function testJoin()
{ {
$this->assertValidDql('FROM User u JOIN u.Group'); $this->assertValidDql('FROM User u JOIN u.UserGroup');
} }
public function testInnerJoin() public function testInnerJoin()
{ {
$this->assertValidDql('FROM User u INNER JOIN u.Group'); $this->assertValidDql('FROM User u INNER JOIN u.UserGroup');
} }
public function testMultipleLeftJoin() public function testMultipleLeftJoin()
{ {
$this->assertValidDql('FROM User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber'); $this->assertValidDql('FROM User u LEFT JOIN u.UserGroup LEFT JOIN u.Phonenumber');
} }
public function testMultipleInnerJoin() public function testMultipleInnerJoin()
{ {
$this->assertValidDql('SELECT u.name FROM User u INNER JOIN u.Group INNER JOIN u.Phonenumber'); $this->assertValidDql('SELECT u.name FROM User u INNER JOIN u.UserGroup INNER JOIN u.Phonenumber');
} }
public function testMultipleInnerJoin2() public function testMultipleInnerJoin2()
{ {
$this->assertValidDql('SELECT u.name FROM User u INNER JOIN u.Group, u.Phonenumber'); $this->assertValidDql('SELECT u.name FROM User u INNER JOIN u.UserGroup, u.Phonenumber');
} }
public function testMixingOfJoins() public function testMixingOfJoins()
{ {
$this->assertValidDql('SELECT u.name, g.name, p.phonenumber FROM User u INNER JOIN u.Group g LEFT JOIN u.Phonenumber p'); $this->assertValidDql('SELECT u.name, g.name, p.phonenumber FROM User u INNER JOIN u.UserGroup g LEFT JOIN u.Phonenumber p');
} }
public function testMixingOfJoins2() public function testMixingOfJoins2()
{ {
$this->assertValidDql('SELECT u.name, g.name, p.phonenumber FROM User u INNER JOIN u.Group.Phonenumber p'); $this->assertValidDql('SELECT u.name, g.name, p.phonenumber FROM User u INNER JOIN u.UserGroup.Phonenumber p');
} }
public function testOrderBySingleColumn() public function testOrderBySingleColumn()
...@@ -256,14 +256,14 @@ class Doctrine_Query_LanguageRecognition_TestCase extends Doctrine_UnitTestCase ...@@ -256,14 +256,14 @@ class Doctrine_Query_LanguageRecognition_TestCase extends Doctrine_UnitTestCase
$this->assertValidDql("SELECT u.name, (SELECT COUNT(p.id) FROM Phonenumber p WHERE p.entity_id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1"); $this->assertValidDql("SELECT u.name, (SELECT COUNT(p.id) FROM Phonenumber p WHERE p.entity_id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1");
} }
public function testInputParameter() public function testPositionalInputParameter()
{ {
$this->assertValidDql('FROM User WHERE u.id = ?'); $this->assertValidDql('FROM User u WHERE u.id = ?');
} }
public function testNamedInputParameter() public function testNamedInputParameter()
{ {
$this->assertValidDql('FROM User WHERE u.id = :id'); $this->assertValidDql('FROM User u WHERE u.id = :id');
} }
public function testCustomJoinsAndWithKeywordSupported() public function testCustomJoinsAndWithKeywordSupported()
...@@ -280,4 +280,39 @@ class Doctrine_Query_LanguageRecognition_TestCase extends Doctrine_UnitTestCase ...@@ -280,4 +280,39 @@ class Doctrine_Query_LanguageRecognition_TestCase extends Doctrine_UnitTestCase
{ {
$this->assertValidDql('FROM Record_City c INDEX BY c.name'); $this->assertValidDql('FROM Record_City c INDEX BY c.name');
} }
public function testIndexBySupportsJoins()
{
$this->assertValidDql('FROM Record_Country c LEFT JOIN c.City c2 INDEX BY c2.name');
}
public function testIndexBySupportsJoins2()
{
$this->assertValidDql('FROM User u INDEX BY u.name LEFT JOIN u.Phonenumber p INDEX BY p.phonenumber');
}
public function testBetweenExpressionSupported()
{
$this->assertValidDql("FROM User u WHERE u.name BETWEEN 'jepso' AND 'zYne'");
}
public function testNotBetweenExpressionSupported()
{
$this->assertValidDql("FROM User u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'");
}
public function testAllExpression()
{
$this->assertValidDql('FROM Employee e WHERE e.salary > ALL (SELECT m.salary FROM Manager m WHERE m.department = e.department)');
}
public function testAnyExpression()
{
$this->assertValidDql('FROM Employee e WHERE e.salary > ANY (SELECT m.salary FROM Manager m WHERE m.department = e.department)');
}
public function testSomeExpression()
{
$this->assertValidDql('FROM Employee e WHERE e.salary > SOME (SELECT m.salary FROM Manager m WHERE m.department = e.department)');
}
} }
...@@ -42,7 +42,7 @@ class Doctrine_Query_Scanner_TestCase extends Doctrine_UnitTestCase ...@@ -42,7 +42,7 @@ class Doctrine_Query_Scanner_TestCase extends Doctrine_UnitTestCase
$scanner = new Doctrine_Query_Scanner('1234'); $scanner = new Doctrine_Query_Scanner('1234');
$token = $scanner->next(); $token = $scanner->next();
$this->assertEqual(Doctrine_Query_Token::T_NUMERIC, $token['type']); $this->assertEqual(Doctrine_Query_Token::T_INTEGER, $token['type']);
$this->assertEqual(1234, $token['value']); $this->assertEqual(1234, $token['value']);
} }
...@@ -51,7 +51,7 @@ class Doctrine_Query_Scanner_TestCase extends Doctrine_UnitTestCase ...@@ -51,7 +51,7 @@ class Doctrine_Query_Scanner_TestCase extends Doctrine_UnitTestCase
$scanner = new Doctrine_Query_Scanner('1.234'); $scanner = new Doctrine_Query_Scanner('1.234');
$token = $scanner->next(); $token = $scanner->next();
$this->assertEqual(Doctrine_Query_Token::T_NUMERIC, $token['type']); $this->assertEqual(Doctrine_Query_Token::T_FLOAT, $token['type']);
$this->assertEqual(1.234, $token['value']); $this->assertEqual(1.234, $token['value']);
} }
...@@ -60,7 +60,7 @@ class Doctrine_Query_Scanner_TestCase extends Doctrine_UnitTestCase ...@@ -60,7 +60,7 @@ class Doctrine_Query_Scanner_TestCase extends Doctrine_UnitTestCase
$scanner = new Doctrine_Query_Scanner('1.2e3'); $scanner = new Doctrine_Query_Scanner('1.2e3');
$token = $scanner->next(); $token = $scanner->next();
$this->assertEqual(Doctrine_Query_Token::T_NUMERIC, $token['type']); $this->assertEqual(Doctrine_Query_Token::T_FLOAT, $token['type']);
$this->assertEqual(1.2e3, $token['value']); $this->assertEqual(1.2e3, $token['value']);
} }
...@@ -69,7 +69,7 @@ class Doctrine_Query_Scanner_TestCase extends Doctrine_UnitTestCase ...@@ -69,7 +69,7 @@ class Doctrine_Query_Scanner_TestCase extends Doctrine_UnitTestCase
$scanner = new Doctrine_Query_Scanner('7E-10'); $scanner = new Doctrine_Query_Scanner('7E-10');
$token = $scanner->next(); $token = $scanner->next();
$this->assertEqual(Doctrine_Query_Token::T_NUMERIC, $token['type']); $this->assertEqual(Doctrine_Query_Token::T_FLOAT, $token['type']);
$this->assertEqual(7E-10, $token['value']); $this->assertEqual(7E-10, $token['value']);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment