[2.0] Fixed issue in changeset calculation.
This commit is contained in:
parent
ae7be288e1
commit
80de567817
6 changed files with 58 additions and 44 deletions
|
@ -32,7 +32,7 @@ use Doctrine\Common\EventManager;
|
|||
final class DriverManager
|
||||
{
|
||||
/**
|
||||
* List of supported drivers and their mappings to the driver class.
|
||||
* List of supported drivers and their mappings to the driver classes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
|
|
@ -87,7 +87,8 @@ abstract class AbstractEntityPersister
|
|||
* Inserts an entity.
|
||||
*
|
||||
* @param object $entity The entity to insert.
|
||||
* @return mixed
|
||||
* @return mixed If the entity uses a post-insert ID generator, the generated
|
||||
* ID is returned, NULL otherwise.
|
||||
*/
|
||||
public function insert($entity)
|
||||
{
|
||||
|
@ -118,7 +119,7 @@ abstract class AbstractEntityPersister
|
|||
*/
|
||||
public function executeInserts()
|
||||
{
|
||||
$tableName = $this->_classMetadata->getTableName();
|
||||
//$tableName = $this->_classMetadata->getTableName();
|
||||
$stmt = $this->_conn->prepare($this->_classMetadata->getInsertSql());
|
||||
foreach ($this->_queuedInserts as $insertData) {
|
||||
$stmt->execute(array_values($insertData));
|
||||
|
@ -154,11 +155,21 @@ abstract class AbstractEntityPersister
|
|||
$this->_conn->delete($this->_classMetadata->getTableName(), $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an entity to delete.
|
||||
*
|
||||
* @param object $entity
|
||||
*/
|
||||
public function addDelete($entity)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes all pending entity deletions.
|
||||
*
|
||||
* @see addDelete()
|
||||
*/
|
||||
public function executeDeletions()
|
||||
{
|
||||
|
||||
|
@ -197,22 +208,12 @@ abstract class AbstractEntityPersister
|
|||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all field mappings of the entire entity hierarchy.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllFieldMappingsInHierarchy()
|
||||
{
|
||||
return $this->_classMetadata->getFieldMappings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the data of an entity for an insert/update operation.
|
||||
*
|
||||
* @param object $entity
|
||||
* @param array $array
|
||||
* @param array $result The reference to the data array.
|
||||
* @param boolean $isInsert
|
||||
*/
|
||||
protected function _prepareData($entity, array &$result, $isInsert = false)
|
||||
|
|
|
@ -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\Persisters;
|
||||
|
@ -30,6 +30,7 @@ namespace Doctrine\ORM\Persisters;
|
|||
* @version $Revision$
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @todo Reimplement.
|
||||
*/
|
||||
class JoinedSubclassPersister extends AbstractEntityPersister
|
||||
{
|
||||
|
|
|
@ -1,11 +1,38 @@
|
|||
<?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.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Persisters;
|
||||
|
||||
/**
|
||||
* Persister for entities that participate in a hierarchy mapped with the
|
||||
* SINGLE_TABLE strategy.
|
||||
*
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @version $Revision: 3406 $
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
*/
|
||||
class SingleTablePersister extends AbstractEntityPersister
|
||||
{
|
||||
//private $_selectColumnList = array();
|
||||
|
||||
public function insert($entity)
|
||||
{
|
||||
return parent::insert($entity);
|
||||
|
@ -18,23 +45,7 @@ class SingleTablePersister extends AbstractEntityPersister
|
|||
// Populate the discriminator column
|
||||
if ($isInsert) {
|
||||
$discColumn = $this->_classMetadata->getDiscriminatorColumn();
|
||||
//$discMap = $this->_classMetadata->getDiscriminatorMap();
|
||||
$result[$discColumn['name']] = $this->_classMetadata->getDiscriminatorValue(); //array_search($this->_entityName, $discMap);
|
||||
$result[$discColumn['name']] = $this->_classMetadata->getDiscriminatorValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
/*public function getAllFieldMappingsInHierarchy()
|
||||
{
|
||||
$fieldMappings = $this->_classMetadata->getFieldMappings();
|
||||
foreach ($this->_classMetadata->getSubclasses() as $subclassName) {
|
||||
$fieldMappings = array_merge(
|
||||
$fieldMappings,
|
||||
$this->_em->getClassMetadata($subclassName)->getFieldMappings()
|
||||
);
|
||||
}
|
||||
return $fieldMappings;
|
||||
}*/
|
||||
}
|
|
@ -325,14 +325,14 @@ class UnitOfWork implements PropertyChangedListener
|
|||
$entitiesToProcess = $class->isChangeTrackingDeferredExplicit() ?
|
||||
$this->_scheduledForDirtyCheck[$className] : $entities;
|
||||
|
||||
if ( ! $class->isInheritanceTypeNone() && count($entitiesToProcess) > 0) {
|
||||
$class = $this->_em->getClassMetadata(get_class($entitiesToProcess[key($entitiesToProcess)]));
|
||||
}
|
||||
|
||||
foreach ($entitiesToProcess as $entity) {
|
||||
$oid = spl_object_hash($entity);
|
||||
$state = $this->getEntityState($entity);
|
||||
|
||||
if ( ! $class->isInheritanceTypeNone()) {
|
||||
$class = $this->_em->getClassMetadata(get_class($entity));
|
||||
}
|
||||
|
||||
// Look for changes in the entity itself by comparing against the
|
||||
// original data we have.
|
||||
if ($state == self::STATE_MANAGED || $state == self::STATE_NEW) {
|
||||
|
|
|
@ -28,17 +28,18 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||
|
||||
$this->_em->save($parent);
|
||||
|
||||
$relatedEntity = new RelatedEntity;
|
||||
$relatedEntity->setName('theRelatedOne');
|
||||
|
||||
$this->_em->save($relatedEntity);
|
||||
|
||||
$child = new ChildEntity;
|
||||
$child->setData('thedata');
|
||||
$child->setNumber(1234);
|
||||
$child->setRelatedEntity($relatedEntity);
|
||||
//$child->setRelatedEntity($relatedEntity);
|
||||
|
||||
$this->_em->save($child);
|
||||
|
||||
$relatedEntity = new RelatedEntity;
|
||||
$relatedEntity->setName('theRelatedOne');
|
||||
$relatedEntity->setOwner($child);
|
||||
|
||||
$this->_em->save($relatedEntity);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
|
Loading…
Add table
Reference in a new issue