Skip to content

Commit 76a825a

Browse files
committed
Fix generation of cache keys for queries with where clauses
1 parent 7cdd61b commit 76a825a

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/CachedBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function getWhereClauses() : string
7676
$value = $where['value'] ?? implode('_', ($where['values'] ?? []));
7777

7878
if (! $value) {
79-
return '';
79+
return $carry . '';
8080
}
8181

8282
return "{$carry}-{$where['column']}_{$value}";

tests/Unit/CachedBuilderTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,10 @@ public function testNestedRelationshipEagerloading()
440440
$this->assertEmpty($liveResults->diffAssoc($cachedResults));
441441
}
442442

443-
public function testNonEagerloadedRelationshipResolvesThroughCachedBuilder()
443+
public function testLazyLoadedRelationshipResolvesThroughCachedBuilder()
444444
{
445445
$books = (new Author)->first()->books;
446-
$key = 'genealabslaravelmodelcachingtestsfixturesbook-books.author_id_1-books.author_id_';
446+
$key = 'genealabslaravelmodelcachingtestsfixturesbook-books.author_id_1';
447447
$tags = [
448448
'genealabslaravelmodelcachingtestsfixturesbook',
449449
];
@@ -458,7 +458,7 @@ public function testNonEagerloadedRelationshipResolvesThroughCachedBuilder()
458458
public function testLazyLoadingOnResourceIsCached()
459459
{
460460
$books = (new AuthorResource((new Author)->first()))->books;
461-
$key = 'genealabslaravelmodelcachingtestsfixturesbook-books.author_id_1-books.author_id_';
461+
$key = 'genealabslaravelmodelcachingtestsfixturesbook-books.author_id_1';
462462
$tags = [
463463
'genealabslaravelmodelcachingtestsfixturesbook',
464464
];
@@ -469,5 +469,4 @@ public function testLazyLoadingOnResourceIsCached()
469469
$this->assertEmpty($books->diffAssoc($cachedResults));
470470
$this->assertEmpty($liveResults->diffAssoc($cachedResults));
471471
}
472-
473472
}

0 commit comments

Comments
 (0)