Skip to content

Commit

Permalink
Revert "Ensure where with array respects boolean (#53147)"
Browse files Browse the repository at this point in the history
This reverts commit d62e92d.
  • Loading branch information
taylorotwell authored Oct 16, 2024
1 parent 3eb58f1 commit 6002e90
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ protected function addArrayOfWheres($column, $boolean, $method = 'where')
return $this->whereNested(function ($query) use ($column, $method, $boolean) {
foreach ($column as $key => $value) {
if (is_numeric($key) && is_array($value)) {
$query->{$method}(...array_values($value), boolean: $boolean);
$query->{$method}(...array_values($value));
} else {
$query->{$method}($key, '=', $value, $boolean);
}
Expand Down
15 changes: 0 additions & 15 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2323,30 +2323,15 @@ public function testWhereWithArrayConditions()
$this->assertSame('select * from "users" where ("foo" = ? and "bar" = ?)', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->where([['foo', 1], ['bar', 2]], boolean: 'or');
$this->assertSame('select * from "users" where ("foo" = ? or "bar" = ?)', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->where(['foo' => 1, 'bar' => 2]);
$this->assertSame('select * from "users" where ("foo" = ? and "bar" = ?)', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->where(['foo' => 1, 'bar' => 2], boolean: 'or');
$this->assertSame('select * from "users" where ("foo" = ? or "bar" = ?)', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->where([['foo', 1], ['bar', '<', 2]]);
$this->assertSame('select * from "users" where ("foo" = ? and "bar" < ?)', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->where([['foo', 1], ['bar', '<', 2]], boolean: 'or');
$this->assertSame('select * from "users" where ("foo" = ? or "bar" < ?)', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());
}

public function testNestedWheres()
Expand Down

0 comments on commit 6002e90

Please sign in to comment.