diff --git a/src/Mapper/Dbal/DbalMapper.php b/src/Mapper/Dbal/DbalMapper.php index 54e465c5..e10a6b2c 100644 --- a/src/Mapper/Dbal/DbalMapper.php +++ b/src/Mapper/Dbal/DbalMapper.php @@ -88,6 +88,14 @@ public function toCollection($data) } + /** @inheritdoc */ + public function clearCollectionCache() + { + parent::clearCollectionCache(); + $this->cacheRM = []; + } + + public function getManyHasManyParameters(PropertyMetadata $sourceProperty, IMapper $targetMapper) { return [ diff --git a/tests/cases/integration/Model/model.clearIdentityMapAndCaches().phpt b/tests/cases/integration/Model/model.clearIdentityMapAndCaches().phpt index 77f27e6b..076cdafe 100644 --- a/tests/cases/integration/Model/model.clearIdentityMapAndCaches().phpt +++ b/tests/cases/integration/Model/model.clearIdentityMapAndCaches().phpt @@ -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); @@ -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); }