Skip to content

Commit ba0f992

Browse files
committed
Fix where parsing for exists and column clauses
1 parent 8b0f6ea commit ba0f992

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [0.2.5] - 2017-10-04
88
### Fixed
9-
- parsing of nested where clauses.
9+
- parsing of nested, exists, and column where clauses.
1010

1111
## [0.2.4] - 2017-10-03
1212
### Added

src/CachedBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ protected function getWhereClauses(array $wheres = []) : string
8080
}
8181

8282
return $wheres->reduce(function ($carry, $where) {
83-
if ($where['type'] === 'Nested') {
83+
if (in_array($where['type'], ['Exists', 'Nested'])) {
8484
return $this->getWhereClauses($where['query']->wheres);
8585
}
8686

87+
if ($where['type'] === 'Column') {
88+
return "{$where['boolean']}_{$where['first']}_{$where['operator']}_{$where['second']}";
89+
}
90+
8791
$value = array_get($where, 'value');
8892

8993
if (in_array($where['type'], ['In', 'Null', 'NotNull'])) {
@@ -98,6 +102,7 @@ protected function getWhereClauses(array $wheres = []) : string
98102
}) ?: '';
99103
}
100104

105+
101106
protected function getWithModels() : string
102107
{
103108
$eagerLoads = collect($this->eagerLoad);

tests/Unit/CachedBuilderTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,19 @@ public function testLazyLoadingOnResourceIsCached()
466466

467467
public function testNestedRelationshipWhereClauseParsing()
468468
{
469+
// -> with('modelA.modelB')
470+
$this->markTestIncomplete();
471+
}
472+
473+
public function testExistsRelationshipWhereClauseParsing()
474+
{
475+
// ->whereHas(...)
476+
$this->markTestIncomplete();
477+
}
478+
479+
public function testColumnsRelationshipWhereClauseParsing()
480+
{
481+
// ???
469482
$this->markTestIncomplete();
470483
}
471484
}

0 commit comments

Comments
 (0)