Skip to content

Commit 05ee597

Browse files
committed
Fix caching of find
1 parent d418fdb commit 05ee597

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/CachedBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function find($id, $columns = ['*'])
6767
}
6868

6969
$arguments = func_get_args();
70-
$cacheKey = $this->makeCacheKey($columns);
70+
$cacheKey = $this->makeCacheKey(['*'], null, "-find_{$id}");
7171
$method = 'find';
7272

7373
return $this->cachedValue($arguments, $cacheKey, $method);

tests/Unit/CachedBuilderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,4 +853,14 @@ public function testSubsequentDisabledCacheQueriesDoNotCache()
853853
$this->assertEmpty($cachedAuthors1);
854854
$this->assertEmpty($cachedAuthors2);
855855
}
856+
857+
public function testSubsequentFindsReturnDifferentModels()
858+
{
859+
$author1 = (new Author)->find(1);
860+
$author2 = (new Author)->find(2);
861+
862+
$this->assertNotEquals($author1, $author2);
863+
$this->assertEquals($author1->id, 1);
864+
$this->assertEquals($author2->id, 2);
865+
}
856866
}

0 commit comments

Comments
 (0)