Skip to content

Commit eddc5a1

Browse files
staudenmeirtaylorotwell
authored andcommitted
Ignore non-where bindings in nested where() constraints (#24000)
1 parent 97edff8 commit eddc5a1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Illuminate/Database/Query/Builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ public function addNestedWhereQuery($query, $boolean = 'and')
12891289

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

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

12951295
return $this;

tests/Database/DatabaseQueryBuilderTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,15 @@ public function testNestedWheres()
10391039
$this->assertEquals([0 => 'foo', 1 => 'bar', 2 => 25], $builder->getBindings());
10401040
}
10411041

1042+
public function testNestedWhereBindings()
1043+
{
1044+
$builder = $this->getBuilder();
1045+
$builder->where('email', '=', 'foo')->where(function ($q) {
1046+
$q->selectRaw('?', ['ignore'])->where('name', '=', 'bar');
1047+
});
1048+
$this->assertEquals([0 => 'foo', 1 => 'bar'], $builder->getBindings());
1049+
}
1050+
10421051
public function testFullSubSelects()
10431052
{
10441053
$builder = $this->getBuilder();

0 commit comments

Comments
 (0)