Commit c9cc9f13 authored by romanb's avatar romanb

[2.0] Parser code review with some cleanups and comments to highlight TODOs.

parent 0b9c990d
......@@ -19,4 +19,9 @@ class BigIntType extends Type
{
return $platform->getBigIntTypeDeclarationSql($fieldDeclaration);
}
public function getTypeCode()
{
return self::CODE_INT;
}
}
\ No newline at end of file
......@@ -22,4 +22,9 @@ class IntegerType extends Type
{
return (int) $value;
}
public function getTypeCode()
{
return self::CODE_INT;
}
}
\ No newline at end of file
......@@ -23,4 +23,9 @@ class SmallIntType
{
return (int) $value;
}
public function getTypeCode()
{
return self::CODE_INT;
}
}
\ No newline at end of file
......@@ -5,8 +5,25 @@ namespace Doctrine\DBAL\Types;
use Doctrine\Common\DoctrineException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
/**
* The base class for so-called Doctrine mapping types.
*
* A Type object is obtained by calling the static {@link getType()} method.
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
abstract class Type
{
/* The following constants represent type codes and mirror the PDO::PARAM_X constants
* to decouple ourself from PDO.
*/
const CODE_BOOL = 5;
const CODE_NULL = 0;
const CODE_INT = 1;
const CODE_STR = 2;
const CODE_LOB = 3;
private static $_typeObjects = array();
private static $_typesMap = array(
'integer' => 'Doctrine\DBAL\Types\IntegerType',
......@@ -39,7 +56,10 @@ abstract class Type
abstract public function getName();
//abstract public function getTypeCode();
public function getTypeCode()
{
return self::CODE_STR;
}
/**
* Factory method to create type instances.
......
......@@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManager;
* Id generator that uses a single-row database table and a hi/lo algorithm.
*
* @since 2.0
* @todo Implementation
*/
class TableGenerator extends AbstractIdGenerator
{
......
......@@ -16,7 +16,7 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Internal;
......
......@@ -16,7 +16,7 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Internal;
......@@ -41,9 +41,9 @@ class CommitOrderNode
private $_relatedNodes = array();
/* The "time" when this node was first discovered during traversal */
private $_discoveryTime;
public $discoveryTime;
/* The "time" when this node was finished during traversal */
private $_finishingTime;
public $finishingTime;
/* The wrapped object */
private $_wrappedObj;
......@@ -109,7 +109,7 @@ class CommitOrderNode
public function visit()
{
$this->markInProgress();
$this->setDiscoveryTime($this->_calculator->getNextTime());
$this->discoveryTime = $this->_calculator->getNextTime();
foreach ($this->getRelatedNodes() as $node) {
if ($node->isNotVisited()) {
......@@ -124,27 +124,7 @@ class CommitOrderNode
$this->markVisited();
$this->_calculator->prependNode($this);
$this->setFinishingTime($this->_calculator->getNextTime());
}
public function setDiscoveryTime($time)
{
$this->_discoveryTime = $time;
}
public function setFinishingTime($time)
{
$this->_finishingTime = $time;
}
public function getDiscoveryTime()
{
return $this->_discoveryTime;
}
public function getFinishingTime()
{
return $this->_finishingTime;
$this->finishingTime = $this->_calculator->getNextTime();
}
public function getRelatedNodes()
......
......@@ -328,7 +328,7 @@ class ObjectHydrator extends AbstractHydrator
// This element will get the associated element attached.
if ($this->_rsm->isMixed && isset($this->_rootAliases[$parent])) {
$first = reset($this->_resultPointers);
// TODO: Exception if $key === null ?
// TODO: Exception if key($first) === null ?
$baseElement = $this->_resultPointers[$parent][key($first)];
} else if (isset($this->_resultPointers[$parent])) {
$baseElement = $this->_resultPointers[$parent];
......
......@@ -118,7 +118,7 @@ class StandardEntityPersister
$paramIndex = 1;
foreach ($insertData[$primaryTableName] as $value) {
$stmt->bindValue($paramIndex++, $value/*, TODO: TYPE */);
$stmt->bindValue($paramIndex++, $value/*, Type::getType()*/);
}
$stmt->execute();
......@@ -235,7 +235,7 @@ class StandardEntityPersister
if (isset($this->_class->associationMappings[$field])) {
$assocMapping = $this->_class->associationMappings[$field];
// Only owning side of 1-1 associations can have a FK column.
// Only owning side of x-1 associations can have a FK column.
if ( ! $assocMapping->isOneToOne() || $assocMapping->isInverseSide()) {
continue;
}
......
......@@ -148,9 +148,6 @@ class Query extends AbstractQuery
$executor = $this->parse()->getSqlExecutor();
}
// Assignments for Enums
//$this->_setEnumParams($this->_parserResult->getEnumParams());
// Converting parameters
$params = $this->_prepareParams($params);
......
......@@ -16,7 +16,7 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
......@@ -26,7 +26,7 @@ namespace Doctrine\ORM\Query\AST;
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
......
......@@ -26,6 +26,7 @@ namespace Doctrine\ORM\Query\AST;
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0
......
......@@ -16,7 +16,7 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\Exec;
......@@ -27,24 +27,23 @@ namespace Doctrine\ORM\Query\Exec;
*
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @todo For a good implementation that uses temporary tables see the Hibernate sources:
* (org.hibernate.hql.ast.exec.MultiTableDeleteExecutor).
* @todo Rename to MultiTableDeleteExecutor
*/
class MultiTableDeleteExecutor extends AbstractExecutor
{
/**
* Enter description here...
*
* @param Doctrine_ORM_Query_AST $AST
* @param Node $AST
*/
public function __construct(\Doctrine\ORM\Query\AST $AST)
public function __construct($AST)
{
// 1. Create a INSERT INTO temptable ... VALUES ( SELECT statement where the SELECT statement
// selects the identifiers and uses the WhereClause of the $AST.
// selects the identifiers and uses the WhereClause of the $AST ).
// 2. Create ID subselect statement used in DELETE .... WHERE ... IN (subselect)
......
......@@ -16,7 +16,7 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\Exec;
......@@ -27,16 +27,15 @@ namespace Doctrine\ORM\Query\Exec;
*
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @link http://www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @todo For a good implementation that uses temporary tables see the Hibernate sources:
* (org.hibernate.hql.ast.exec.MultiTableUpdateExecutor).
* @todo Rename to MultiTableUpdateExecutor
*/
class MultiTableUpdateExecutor extends AbstractExecutor
{
public function __construct(\Doctrine\ORM\Query\AST $AST)
public function __construct($AST)
{
// TODO: Inspect the AST, create the necessary SQL queries and store them
// in $this->_sqlStatements
......
......@@ -164,30 +164,6 @@ class Lexer
}
}
/**
* Attempts to match the given token with the current lookahead token.
*
* If they match, the lexer moves on to the next token, otherwise a syntax error
* is raised.
*
* @param int|string token type or value
* @return bool True, if tokens match; false otherwise.
*/
/*public function match($token)
{
if (is_string($token)) {
$isMatch = ($this->lookahead['value'] === $token);
} else {
$isMatch = ($this->lookahead['type'] === $token);
}
if ( ! $isMatch) {
$this->syntaxError($this->getLiteral($token));
}
$this->moveNext();
}*/
/**
* Checks if an identifier is a keyword and returns its correct type.
*
......
This diff is collapsed.
......@@ -27,7 +27,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
public function testNewHydrationSimpleQueryArrayHydrationPerformance()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u');
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addFieldResult('u', 'u__username', 'username');
......@@ -82,9 +82,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
public function testNewHydrationMixedQueryFetchJoinArrayHydrationPerformance()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u');
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityResult(
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
'Doctrine\Tests\Models\CMS\CmsPhonenumber',
'p',
'u',
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers')
......@@ -151,7 +151,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
public function testSimpleQueryObjectHydrationPerformance()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u');
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addFieldResult('u', 'u__username', 'username');
......@@ -194,6 +194,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
$this->setMaxRunningTime(5);
$result = $hydrator->hydrateAll($stmt, $rsm);
echo count($result);
}
/**
......@@ -204,9 +205,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
public function testMixedQueryFetchJoinObjectHydrationPerformance()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u');
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityResult(
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
'Doctrine\Tests\Models\CMS\CmsPhonenumber',
'p',
'u',
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers')
......
......@@ -59,7 +59,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function testInvalidSelectSingleComponentWithAsterisk()
{
$this->assertInvalidDql('SELECT p FROM Doctrine\Tests\Models\CMS\CmsUser u');
//$this->assertInvalidDql('SELECT p FROM Doctrine\Tests\Models\CMS\CmsUser u', true);
}
public function testSelectSingleComponentWithMultipleColumns()
......
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