1
0
mirror of synced 2025-02-21 14:43:14 +03:00

Revert "Fixed issue with fetched association not being considered during changeSet calculation. Fixes DDC-1545."

This reverts commit a8478d5766e2cc4185612af680b7f6bcd83af61e.
This commit is contained in:
Benjamin Eberlei 2011-12-19 16:31:26 +01:00
parent 108cb53eef
commit b1b10042d2
3 changed files with 17 additions and 18 deletions

View File

@ -978,13 +978,17 @@ class SqlWalker implements TreeWalker
*/ */
public function walkCoalesceExpression($coalesceExpression) public function walkCoalesceExpression($coalesceExpression)
{ {
$sql = 'COALESCE(';
$scalarExpressions = array(); $scalarExpressions = array();
foreach ($coalesceExpression->scalarExpressions as $scalarExpression) { foreach ($coalesceExpression->scalarExpressions as $scalarExpression) {
$scalarExpressions[] = $this->walkSimpleArithmeticExpression($scalarExpression); $scalarExpressions[] = $this->walkSimpleArithmeticExpression($scalarExpression);
} }
return 'COALESCE(' . implode(', ', $scalarExpressions) . ')'; $sql .= implode(', ', $scalarExpressions) . ')';
return $sql;
} }
/** /**

View File

@ -705,6 +705,7 @@ class UnitOfWork implements PropertyChangedListener
foreach ($unwrappedValue as $key => $entry) { foreach ($unwrappedValue as $key => $entry) {
$state = $this->getEntityState($entry, self::STATE_NEW); $state = $this->getEntityState($entry, self::STATE_NEW);
$oid = spl_object_hash($entry);
switch ($state) { switch ($state) {
case self::STATE_NEW: case self::STATE_NEW:
@ -2292,14 +2293,13 @@ class UnitOfWork implements PropertyChangedListener
$id = array($class->identifier[0] => $idHash); $id = array($class->identifier[0] => $idHash);
} }
$overrideLocalValues = true;
if (isset($this->identityMap[$class->rootEntityName][$idHash])) { if (isset($this->identityMap[$class->rootEntityName][$idHash])) {
$entity = $this->identityMap[$class->rootEntityName][$idHash]; $entity = $this->identityMap[$class->rootEntityName][$idHash];
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
if ($entity instanceof Proxy && ! $entity->__isInitialized__) { if ($entity instanceof Proxy && ! $entity->__isInitialized__) {
$entity->__isInitialized__ = true; $entity->__isInitialized__ = true;
$overrideLocalValues = true;
if ($entity instanceof NotifyPropertyChanged) { if ($entity instanceof NotifyPropertyChanged) {
$entity->addPropertyChangedListener($this); $entity->addPropertyChangedListener($this);
@ -2308,7 +2308,7 @@ class UnitOfWork implements PropertyChangedListener
$overrideLocalValues = isset($hints[Query::HINT_REFRESH]); $overrideLocalValues = isset($hints[Query::HINT_REFRESH]);
// If only a specific entity is set to refresh, check that it's the one // If only a specific entity is set to refresh, check that it's the one
if (isset($hints[Query::HINT_REFRESH_ENTITY])) { if(isset($hints[Query::HINT_REFRESH_ENTITY])) {
$overrideLocalValues = $hints[Query::HINT_REFRESH_ENTITY] === $entity; $overrideLocalValues = $hints[Query::HINT_REFRESH_ENTITY] === $entity;
// inject ObjectManager into just loaded proxies. // inject ObjectManager into just loaded proxies.
@ -2333,6 +2333,8 @@ class UnitOfWork implements PropertyChangedListener
if ($entity instanceof NotifyPropertyChanged) { if ($entity instanceof NotifyPropertyChanged) {
$entity->addPropertyChangedListener($this); $entity->addPropertyChangedListener($this);
} }
$overrideLocalValues = true;
} }
if ( ! $overrideLocalValues) { if ( ! $overrideLocalValues) {
@ -2360,10 +2362,6 @@ class UnitOfWork implements PropertyChangedListener
foreach ($class->associationMappings as $field => $assoc) { foreach ($class->associationMappings as $field => $assoc) {
// Check if the association is not among the fetch-joined associations already. // Check if the association is not among the fetch-joined associations already.
if (isset($hints['fetchAlias']) && isset($hints['fetched'][$hints['fetchAlias']][$field])) { if (isset($hints['fetchAlias']) && isset($hints['fetched'][$hints['fetchAlias']][$field])) {
// DDC-1545: Fetched associations must have original entity data set.
// Define NULL value right now, since next iteration may fill it with actual value.
$this->originalEntityData[$oid][$field] = null;
continue; continue;
} }
@ -2384,15 +2382,12 @@ class UnitOfWork implements PropertyChangedListener
foreach ($assoc['targetToSourceKeyColumns'] as $targetColumn => $srcColumn) { foreach ($assoc['targetToSourceKeyColumns'] as $targetColumn => $srcColumn) {
$joinColumnValue = isset($data[$srcColumn]) ? $data[$srcColumn] : null; $joinColumnValue = isset($data[$srcColumn]) ? $data[$srcColumn] : null;
// Skip is join column value is null if ($joinColumnValue !== null) {
if ($joinColumnValue === null) { if ($targetClass->containsForeignIdentifier) {
continue; $associatedId[$targetClass->getFieldForColumn($targetColumn)] = $joinColumnValue;
} } else {
$associatedId[$targetClass->fieldNames[$targetColumn]] = $joinColumnValue;
if ($targetClass->containsForeignIdentifier) { }
$associatedId[$targetClass->getFieldForColumn($targetColumn)] = $joinColumnValue;
} else {
$associatedId[$targetClass->fieldNames[$targetColumn]] = $joinColumnValue;
} }
} }

View File

@ -36,7 +36,7 @@ class CmsArticle
* @Version @column(type="integer") * @Version @column(type="integer")
*/ */
public $version; public $version;
public function setAuthor(CmsUser $author) { public function setAuthor(CmsUser $author) {
$this->user = $author; $this->user = $author;
} }