Skip to content

Commit

Permalink
DbalMapper - clearCollectionCache also clears relationship mapper cache
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 authored and hrach committed Feb 17, 2017
1 parent 85cff54 commit 0dd82ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Mapper/Dbal/DbalMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ public function toCollection($data)
}


/** @inheritdoc */
public function clearCollectionCache()
{
parent::clearCollectionCache();
$this->cacheRM = [];
}


public function getManyHasManyParameters(PropertyMetadata $sourceProperty, IMapper $targetMapper)
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ModelClearIdentityMapAndCachesTest extends DataTestCase
public function testBasics()
{
$book1 = $this->orm->books->getById(1);
$author1 = $book1->author;
$author1Id = $author1->id;
$book2 = $this->orm->books->getById(1);

Assert::equal($book1, $book2);
Expand All @@ -29,6 +31,9 @@ class ModelClearIdentityMapAndCachesTest extends DataTestCase

$book3 = $this->orm->books->getById(1);
Assert::notEqual($book1, $book3);
$author3 = $book3->author;
Assert::notEqual($author1, $author3);
Assert::same($author1Id, $author3->id);
}


Expand Down

0 comments on commit 0dd82ca

Please sign in to comment.