[2.0] Cosmetics.
This commit is contained in:
parent
311cff87d3
commit
0c8a35f731
@ -350,6 +350,7 @@ class ObjectHydrator extends AbstractHydrator
|
||||
$indexExists = isset($this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]]);
|
||||
$index = $indexExists ? $this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]] : false;
|
||||
$indexIsValid = $index !== false ? $this->isIndexKeyInUse($baseElement, $relationAlias, $index) : false;
|
||||
|
||||
if ( ! $indexExists || ! $indexIsValid) {
|
||||
$element = $this->getEntity($data, $dqlAlias);
|
||||
|
||||
@ -397,17 +398,13 @@ class ObjectHydrator extends AbstractHydrator
|
||||
}
|
||||
} else {
|
||||
if ( ! $this->_ce[$parentClass]->reflFields[$relationAlias]->getValue($baseElement)) {
|
||||
if ( ! isset($nonemptyComponents[$dqlAlias])) {
|
||||
//$this->setRelatedElement($baseElement, $relationAlias, null);
|
||||
} else {
|
||||
if (isset($nonemptyComponents[$dqlAlias])) {
|
||||
$this->setRelatedElement($baseElement, $relationAlias, $this->getEntity($data, $dqlAlias));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$coll = $this->_ce[$parentClass]
|
||||
->reflFields[$relationAlias]
|
||||
->getValue($baseElement);
|
||||
$coll = $this->_ce[$parentClass]->reflFields[$relationAlias]->getValue($baseElement);
|
||||
|
||||
if ($coll !== null) {
|
||||
$this->updateResultPointer($coll, $index, $dqlAlias);
|
||||
|
@ -87,6 +87,9 @@ class StandardEntityPersister
|
||||
* Initializes a new instance of a class derived from AbstractEntityPersister
|
||||
* that uses the given EntityManager and persists instances of the class described
|
||||
* by the given class metadata descriptor.
|
||||
*
|
||||
* @param EntityManager $em
|
||||
* @param ClassMetadata $class
|
||||
*/
|
||||
public function __construct(EntityManager $em, ClassMetadata $class)
|
||||
{
|
||||
@ -346,7 +349,7 @@ class StandardEntityPersister
|
||||
foreach ($stmt->fetch(Connection::FETCH_ASSOC) as $column => $value) {
|
||||
$fieldName = $this->_class->fieldNames[$column];
|
||||
$data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName))
|
||||
->convertToPHPValue($value, $this->_platform);
|
||||
->convertToPHPValue($value, $this->_platform);
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
@ -394,20 +397,19 @@ class StandardEntityPersister
|
||||
*
|
||||
* @param array $criteria
|
||||
* @return string The SQL.
|
||||
* @todo Quote identifier.
|
||||
*/
|
||||
protected function _getSelectSingleEntitySql(array $criteria)
|
||||
{
|
||||
$columnList = '';
|
||||
foreach ($this->_class->columnNames as $column) {
|
||||
if ($columnList != '') $columnList .= ', ';
|
||||
$columnList .= $column;
|
||||
$columnList .= $this->_conn->quoteIdentifier($column);
|
||||
}
|
||||
|
||||
$conditionSql = '';
|
||||
foreach ($criteria as $field => $value) {
|
||||
if ($conditionSql != '') $conditionSql .= ' AND ';
|
||||
$conditionSql .= $this->_class->columnNames[$field] . ' = ?';
|
||||
$conditionSql .= $this->_conn->quoteIdentifier($this->_class->columnNames[$field]) . ' = ?';
|
||||
}
|
||||
|
||||
return 'SELECT ' . $columnList . ' FROM ' . $this->_class->getTableName()
|
||||
|
@ -1355,6 +1355,10 @@ class UnitOfWork implements PropertyChangedListener
|
||||
foreach ($data as $field => $value) {
|
||||
if (isset($class->reflFields[$field])) {
|
||||
$currentValue = $class->reflFields[$field]->getValue($entity);
|
||||
// Only override the current value if:
|
||||
// a) There was no original value yet (nothing in _originalEntityData)
|
||||
// or
|
||||
// b) The original value is the same as the current value (it was not changed).
|
||||
if ( ! isset($this->_originalEntityData[$oid][$field]) ||
|
||||
$currentValue == $this->_originalEntityData[$oid][$field]) {
|
||||
$class->reflFields[$field]->setValue($entity, $value);
|
||||
@ -1469,7 +1473,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
public function size()
|
||||
{
|
||||
$count = 0;
|
||||
foreach ($this->_identityMap as $entitySet) $count += count($entitySet);
|
||||
foreach ($this->_identityMap as $entitySet) {
|
||||
$count += count($entitySet);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
||||
/**
|
||||
* Times for comparison:
|
||||
*
|
||||
* [romanb: 10000 rows => 1.8 seconds]
|
||||
* [romanb: 10000 rows => 1 second]
|
||||
*
|
||||
* MAXIMUM TIME: 3 seconds
|
||||
* MAXIMUM TIME: 2 seconds
|
||||
*/
|
||||
public function testSimpleQueryArrayHydrationPerformance()
|
||||
{
|
||||
@ -68,7 +68,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
||||
$stmt = new HydratorMockStatement($resultSet);
|
||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em);
|
||||
|
||||
$this->setMaxRunningTime(3);
|
||||
$this->setMaxRunningTime(2);
|
||||
$s = microtime(true);
|
||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||
$e = microtime(true);
|
||||
@ -78,9 +78,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
||||
/**
|
||||
* Times for comparison:
|
||||
*
|
||||
* [romanb: 10000 rows => 3.0 seconds]
|
||||
* [romanb: 10000 rows => 1.4 seconds]
|
||||
*
|
||||
* MAXIMUM TIME: 4 seconds
|
||||
* MAXIMUM TIME: 3 seconds
|
||||
*/
|
||||
public function testMixedQueryFetchJoinArrayHydrationPerformance()
|
||||
{
|
||||
@ -142,7 +142,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
||||
$stmt = new HydratorMockStatement($resultSet);
|
||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em);
|
||||
|
||||
$this->setMaxRunningTime(4);
|
||||
$this->setMaxRunningTime(3);
|
||||
$s = microtime(true);
|
||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||
$e = microtime(true);
|
||||
@ -150,9 +150,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* [romanb: 10000 rows => 3.8 seconds]
|
||||
* [romanb: 10000 rows => 1.5 seconds]
|
||||
*
|
||||
* MAXIMUM TIME: 5 seconds
|
||||
* MAXIMUM TIME: 3 seconds
|
||||
*/
|
||||
public function testSimpleQueryObjectHydrationPerformance()
|
||||
{
|
||||
@ -198,7 +198,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
||||
$stmt = new HydratorMockStatement($resultSet);
|
||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
||||
|
||||
$this->setMaxRunningTime(5);
|
||||
$this->setMaxRunningTime(3);
|
||||
$s = microtime(true);
|
||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||
$e = microtime(true);
|
||||
@ -206,9 +206,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* [romanb: 2000 rows => 3.1 seconds]
|
||||
* [romanb: 2000 rows => 1 second]
|
||||
*
|
||||
* MAXIMUM TIME: 4 seconds
|
||||
* MAXIMUM TIME: 2 seconds
|
||||
*/
|
||||
public function testMixedQueryFetchJoinObjectHydrationPerformance()
|
||||
{
|
||||
@ -270,7 +270,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
||||
$stmt = new HydratorMockStatement($resultSet);
|
||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
||||
|
||||
$this->setMaxRunningTime(4);
|
||||
$this->setMaxRunningTime(2);
|
||||
$s = microtime(true);
|
||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||
$e = microtime(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user