Skip to content

Commit 4f07ab3

Browse files
committed
Merge pull request #70 from Hajneej/bug-selection-cache
cache invalidation bug
2 parents 5522671 + f7ab4a8 commit 4f07ab3

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/Database/Table/Selection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ protected function emptyResultSet($saveCache = TRUE)
538538
$this->specificCacheKey = NULL;
539539
$this->generalCacheKey = NULL;
540540
$this->refCache['referencingPrototype'] = [];
541+
$this->refCache['referenced'] = [];
541542
}
542543

543544

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/**
4+
* @dataProvider? ../../databases.ini
5+
*/
6+
7+
use Tester\Assert;
8+
9+
require __DIR__ . '/../../connect.inc.php'; // create $connection
10+
11+
Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../../files/{$driverName}-nette_test1.sql");
12+
13+
14+
test(function () use ($context) {
15+
$selection = $context->table('book');
16+
$selection->get(2)->author->name; //reading via reference
17+
18+
$context->table('book')->get(2)->author->update(['name' => 'New name']);
19+
$context->table('book')->get(2)->update(['title' => 'New book title']);
20+
21+
$selection->limit(NULL); //should invalidate cache of data and references
22+
$book = $selection->get(2);
23+
24+
Assert::same('New book title', $book->title); //data cache invalidated
25+
Assert::same('New name', $book->author->name); //references NOT invalidated
26+
});

0 commit comments

Comments
 (0)