Skip to content

Commit 8b0f6ea

Browse files
committed
Fix nested where clause parsing
1 parent 34f59b8 commit 8b0f6ea

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.5] - 2017-10-04
8+
### Fixed
9+
- parsing of nested where clauses.
10+
711
## [0.2.4] - 2017-10-03
812
### Added
913
- .gitignore file to reduce download size for production environment.

src/CachedBuilder.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,19 @@ protected function getQueryColumns(array $columns) : string
7171
return '_' . implode('_', $columns);
7272
}
7373

74-
protected function getWhereClauses() : string
74+
protected function getWhereClauses(array $wheres = []) : string
7575
{
76-
return collect($this->query->wheres)->reduce(function ($carry, $where) {
76+
$wheres = collect($wheres);
77+
78+
if ($wheres->isEmpty()) {
79+
$wheres = collect($this->query->wheres);
80+
}
81+
82+
return $wheres->reduce(function ($carry, $where) {
83+
if ($where['type'] === 'Nested') {
84+
return $this->getWhereClauses($where['query']->wheres);
85+
}
86+
7787
$value = array_get($where, 'value');
7888

7989
if (in_array($where['type'], ['In', 'Null', 'NotNull'])) {

tests/Unit/CachedBuilderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,9 @@ public function testLazyLoadingOnResourceIsCached()
463463
$this->assertEmpty($books->diffAssoc($cachedResults));
464464
$this->assertEmpty($liveResults->diffAssoc($cachedResults));
465465
}
466+
467+
public function testNestedRelationshipWhereClauseParsing()
468+
{
469+
$this->markTestIncomplete();
470+
}
466471
}

0 commit comments

Comments
 (0)