From 6002e9004db09a7e118b3836a2e6f3c2d7a5e536 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 16 Oct 2024 09:07:43 -0500 Subject: [PATCH] Revert "Ensure where with array respects boolean (#53147)" This reverts commit d62e92d781327bc2d272724f9f4be9dd62d5bceb. --- src/Illuminate/Database/Query/Builder.php | 2 +- tests/Database/DatabaseQueryBuilderTest.php | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index ff5c7be04605..49a68820ed9c 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), boolean: $boolean); + $query->{$method}(...array_values($value)); } else { $query->{$method}($key, '=', $value, $boolean); } diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index d635a7e2efc3..18ab730f2f69 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -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()