diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 49a68820ed9..ff5c7be0460 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -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)); + $query->{$method}(...array_values($value), boolean: $boolean); } else { $query->{$method}($key, '=', $value, $boolean); } diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index 18ab730f2f6..d635a7e2efc 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -2323,15 +2323,30 @@ 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()