Skip to content

Commit 837dedb

Browse files
committed
Fix bad database iteration on MySQL and SQL Server
1 parent 0864a23 commit 837dedb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Note: you may refer to `README.md` for description of features.
33

44
## Dev (WIP)
5+
- Fixed database cache evictor entirely not working for MySQL and SQL Server
6+
- Sample error message on MySQL: `You have an error in your SQL syntax [...]`
57
- Fixed wrong console kernel schedule example code
68

79
## 2.0.6 (2025-07-11)

src/Database/DatabaseEvictStrategy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DatabaseEvictStrategy extends AbstractEvictStrategy
2929

3030
public function __construct(string $storeName)
3131
{
32-
parent::__construct($storeName);
32+
parent::__construct($storeName);
3333

3434
// read cache details, and set the specs
3535
$storeConn = config("cache.stores.{$storeName}.connection");
@@ -125,9 +125,9 @@ protected function yieldCacheTableItems(): \Generator
125125
// with SUBSTRING, we are clear we want a case-sensitive match, and we might potentially get collation-correct matching
126126
$record = $this->dbConn
127127
->table($this->dbTable)
128-
->select(['key', 'expiration', DB::raw('LENGTH(key) AS key_bytes'), DB::raw('LENGTH(value) AS value_bytes')])
128+
->select(['key', 'expiration', DB::raw('LENGTH(`key`) AS key_bytes'), DB::raw('LENGTH(value) AS value_bytes')])
129129
->where('key', '>', $currentActualKey)
130-
->where(DB::raw("SUBSTRING(key, 1, $prefixLength)"), '=', $cachePrefix)
130+
->where(DB::raw("SUBSTRING(`key`, 1, $prefixLength)"), '=', $cachePrefix)
131131
// PostgreSQL: if no sorting specified, then will ignore primary key index/ordering, which breaks the intended workflow
132132
->orderBy('key')
133133
->limit(1)

0 commit comments

Comments
 (0)