Skip to content

Commit b0efb66

Browse files
author
Viktoras Morkūnas
committed
Fix nested where binding issue
1 parent 4ac8702 commit b0efb66

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/CacheKey.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ protected function getNestedClauses(array $where) : string
164164
return "";
165165
}
166166

167-
$this->currentBinding++;
168-
169167
return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
170168
}
171169

tests/Integration/CachedBuilder/WhereRawTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,19 @@ public function testNestedWhereRawClauses()
8989

9090
$this->assertEquals($expectedIds, $authors->pluck("id")->toArray());
9191
}
92+
93+
public function testNestedWhereRawWithBindings()
94+
{
95+
$books = (new Book)
96+
->where(function ($query) {
97+
$query->whereRaw("title like ? or description like ? or published_at like ? or price like ?", ['%larravel%', '%larravel%', '%larravel%', '%larravel%',]);
98+
})->get();
99+
100+
$uncachedBooks = (new UncachedBook)
101+
->where(function ($query) {
102+
$query->whereRaw("title like ? or description like ? or published_at like ? or price like ?", ['%larravel%', '%larravel%', '%larravel%', '%larravel%',]);
103+
})->get();
104+
105+
$this->assertEquals($books->pluck("id"), $uncachedBooks->pluck("id"));
106+
}
92107
}

0 commit comments

Comments
 (0)