Skip to content

Commit

Permalink
Fixing issue with custom id being sent with update everytime.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Aug 7, 2010
1 parent c45ba00 commit ad8a782
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Hydrator.php
Expand Up @@ -104,6 +104,8 @@ public function hydrate($document, &$data)
// Set the document identifier // Set the document identifier
if (isset($data['_id'])) { if (isset($data['_id'])) {
$metadata->setIdentifierValue($document, $data['_id']); $metadata->setIdentifierValue($document, $data['_id']);
$data[$metadata->identifier] = $data['_id'];
unset($data['_id']);
} }
return $document; return $document;
} }
Expand Down
3 changes: 1 addition & 2 deletions lib/Doctrine/ODM/MongoDB/UnitOfWork.php
Expand Up @@ -385,8 +385,7 @@ public function computeChangeSet(Mapping\ClassMetadata $class, $document)
$coll->setDirty( ! $coll->isEmpty()); $coll->setDirty( ! $coll->isEmpty());
$class->reflFields[$name]->setValue($document, $coll); $class->reflFields[$name]->setValue($document, $coll);
$actualData[$name] = $coll; $actualData[$name] = $coll;
} } elseif ($class->isCollectionValuedEmbed($name) && $actualData[$name] !== null
if ($class->isCollectionValuedEmbed($name) && $actualData[$name] !== null
&& ! ($actualData[$name] instanceof Collection)) { && ! ($actualData[$name] instanceof Collection)) {
// If $actualData[$name] is not a Collection then use an ArrayCollection. // If $actualData[$name] is not a Collection then use an ArrayCollection.
if ( ! $actualData[$name] instanceof Collection) { if ( ! $actualData[$name] instanceof Collection) {
Expand Down

0 comments on commit ad8a782

Please sign in to comment.