Skip to content

Commit

Permalink
Ignore non-where bindings in nested where() constraints (laravel#24000)
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir authored and leoleoasd committed May 21, 2018
1 parent 8c33edf commit 9dde818
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ public function addNestedWhereQuery($query, $boolean = 'and')

$this->wheres[] = compact('type', 'query', 'boolean');

$this->addBinding($query->getBindings(), 'where');
$this->addBinding($query->getRawBindings()['where'], 'where');
}

return $this;
Expand Down
9 changes: 9 additions & 0 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,15 @@ public function testNestedWheres()
$this->assertEquals([0 => 'foo', 1 => 'bar', 2 => 25], $builder->getBindings());
}

public function testNestedWhereBindings()
{
$builder = $this->getBuilder();
$builder->where('email', '=', 'foo')->where(function ($q) {
$q->selectRaw('?', ['ignore'])->where('name', '=', 'bar');
});
$this->assertEquals([0 => 'foo', 1 => 'bar'], $builder->getBindings());
}

public function testFullSubSelects()
{
$builder = $this->getBuilder();
Expand Down

0 comments on commit 9dde818

Please sign in to comment.