diff --git a/src/Database/Table/Selection.php b/src/Database/Table/Selection.php index 01d61b19a..9c5f6af26 100644 --- a/src/Database/Table/Selection.php +++ b/src/Database/Table/Selection.php @@ -557,6 +557,7 @@ protected function emptyResultSet($saveCache = TRUE) $this->specificCacheKey = NULL; $this->generalCacheKey = NULL; $this->refCache['referencingPrototype'] = []; + $this->refCache['referenced'] = []; } diff --git a/tests/Database/Table/bugs/Selection.emptyResultSet.phpt b/tests/Database/Table/bugs/Selection.emptyResultSet.phpt new file mode 100644 index 000000000..1aa5f8764 --- /dev/null +++ b/tests/Database/Table/bugs/Selection.emptyResultSet.phpt @@ -0,0 +1,26 @@ +table('book'); + $selection->get(2)->author->name; //reading via reference + + $context->table('book')->get(2)->author->update(['name' => 'New name']); + $context->table('book')->get(2)->update(['title' => 'New book title']); + + $selection->limit(NULL); //should invalidate cache of data and references + $book = $selection->get(2); + + Assert::same('New book title', $book->title); //data cache invalidated + Assert::same('New name', $book->author->name); //references NOT invalidated +});