From 6ac84d9149bae03c386f69677709602cdf3d3033 Mon Sep 17 00:00:00 2001
From: bert-w <bertwijnhoven@hotmail.com>
Date: Tue, 27 Feb 2024 23:11:46 +0100
Subject: [PATCH] cleanup

---
 src/Illuminate/Database/Connection.php        |  33 ------
 .../Database/ConnectionInterface.php          |   2 +-
 tests/Database/DatabaseQueryBuilderTest.php   | 111 ------------------
 .../Integration/Database/QueryBuilderTest.php |  36 ++----
 4 files changed, 11 insertions(+), 171 deletions(-)

diff --git a/src/Illuminate/Database/Connection.php b/src/Illuminate/Database/Connection.php
index 9aa5fb61a861..a9f29dc2e231 100755
--- a/src/Illuminate/Database/Connection.php
+++ b/src/Illuminate/Database/Connection.php
@@ -117,13 +117,6 @@ class Connection implements ConnectionInterface
      */
     protected $fetchMode = PDO::FETCH_OBJ;
 
-    /**
-     * The fetch mode override for $statement->fetchAll() calls.
-     *
-     * @var array
-     */
-    protected $fetchAllArgs = [];
-
     /**
      * The number of active transactions.
      *
@@ -495,32 +488,6 @@ public function cursor($query, $bindings = [], $useReadPdo = true)
         }
     }
 
-    /**
-     * Set the arguments for calling $statement->fetchAll().
-     *
-     * @param  int  $mode
-     * @param  mixed  ...$args
-     * @return $this
-     */
-    public function setFetchAllArgs($mode, ...$args)
-    {
-        $this->fetchAllArgs = [$mode, ...$args];
-
-        return $this;
-    }
-
-    /**
-     * Reset the arguments for calling $statement->fetchAll().
-     *
-     * @return $this
-     */
-    public function resetFetchAllArgs()
-    {
-        $this->fetchAllArgs = [];
-
-        return $this;
-    }
-
     /**
      * Configure the PDO prepared statement.
      *
diff --git a/src/Illuminate/Database/ConnectionInterface.php b/src/Illuminate/Database/ConnectionInterface.php
index 288adb4206e3..7d7f2933ddb1 100755
--- a/src/Illuminate/Database/ConnectionInterface.php
+++ b/src/Illuminate/Database/ConnectionInterface.php
@@ -53,7 +53,7 @@ public function scalar($query, $bindings = [], $useReadPdo = true);
      * @param  bool  $useReadPdo
      * @return array
      */
-    public function select($query, $bindings = [], $useReadPdo = true);
+    public function select($query, $bindings = [], $useReadPdo = true, FetchMode $fetchMode = null);
 
     /**
      * Run a select statement against the database and returns a generator.
diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php
index 2afffd9fbde8..9ac232e78531 100755
--- a/tests/Database/DatabaseQueryBuilderTest.php
+++ b/tests/Database/DatabaseQueryBuilderTest.php
@@ -2648,117 +2648,6 @@ public function testLeftJoinLateralSqlServer()
         $this->assertSame('select * from [users] outer apply (select * from [contacts] where [contracts].[user_id] = [users].[id]) as [sub]', $builder->toSql());
     }
 
-    public function testJoinLateral()
-    {
-        $builder = $this->getMySqlBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $builder->from('users')->joinLateral('select * from `contacts` where `contracts`.`user_id` = `users`.`id`', 'sub');
-        $this->assertSame('select * from `users` inner join lateral (select * from `contacts` where `contracts`.`user_id` = `users`.`id`) as `sub` on true', $builder->toSql());
-
-        $builder = $this->getMySqlBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $builder->from('users')->joinLateral(function ($q) {
-            $q->from('contacts')->whereColumn('contracts.user_id', 'users.id');
-        }, 'sub');
-        $this->assertSame('select * from `users` inner join lateral (select * from `contacts` where `contracts`.`user_id` = `users`.`id`) as `sub` on true', $builder->toSql());
-
-        $builder = $this->getMySqlBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $sub = $this->getMySqlBuilder();
-        $sub->getConnection()->shouldReceive('getDatabaseName');
-        $eloquentBuilder = new EloquentBuilder($sub->from('contacts')->whereColumn('contracts.user_id', 'users.id'));
-        $builder->from('users')->joinLateral($eloquentBuilder, 'sub');
-        $this->assertSame('select * from `users` inner join lateral (select * from `contacts` where `contracts`.`user_id` = `users`.`id`) as `sub` on true', $builder->toSql());
-
-        $sub1 = $this->getMySqlBuilder();
-        $sub1->getConnection()->shouldReceive('getDatabaseName');
-        $sub1 = $sub1->from('contacts')->whereColumn('contracts.user_id', 'users.id')->where('name', 'foo');
-
-        $sub2 = $this->getMySqlBuilder();
-        $sub2->getConnection()->shouldReceive('getDatabaseName');
-        $sub2 = $sub2->from('contacts')->whereColumn('contracts.user_id', 'users.id')->where('name', 'bar');
-
-        $builder = $this->getMySqlBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $builder->from('users')->joinLateral($sub1, 'sub1')->joinLateral($sub2, 'sub2');
-
-        $expected = 'select * from `users` ';
-        $expected .= 'inner join lateral (select * from `contacts` where `contracts`.`user_id` = `users`.`id` and `name` = ?) as `sub1` on true ';
-        $expected .= 'inner join lateral (select * from `contacts` where `contracts`.`user_id` = `users`.`id` and `name` = ?) as `sub2` on true';
-
-        $this->assertEquals($expected, $builder->toSql());
-        $this->assertEquals(['foo', 'bar'], $builder->getRawBindings()['join']);
-
-        $this->expectException(InvalidArgumentException::class);
-        $builder = $this->getMySqlBuilder();
-        $builder->from('users')->joinLateral(['foo'], 'sub');
-    }
-
-    public function testJoinLateralSQLite()
-    {
-        $this->expectException(RuntimeException::class);
-        $builder = $this->getSQLiteBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $builder->from('users')->joinLateral(function ($q) {
-            $q->from('contacts')->whereColumn('contracts.user_id', 'users.id');
-        }, 'sub')->toSql();
-    }
-
-    public function testJoinLateralPostgres()
-    {
-        $builder = $this->getPostgresBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $builder->from('users')->joinLateral(function ($q) {
-            $q->from('contacts')->whereColumn('contracts.user_id', 'users.id');
-        }, 'sub');
-        $this->assertSame('select * from "users" inner join lateral (select * from "contacts" where "contracts"."user_id" = "users"."id") as "sub" on true', $builder->toSql());
-    }
-
-    public function testJoinLateralSqlServer()
-    {
-        $builder = $this->getSqlServerBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $builder->from('users')->joinLateral(function ($q) {
-            $q->from('contacts')->whereColumn('contracts.user_id', 'users.id');
-        }, 'sub');
-        $this->assertSame('select * from [users] cross apply (select * from [contacts] where [contracts].[user_id] = [users].[id]) as [sub]', $builder->toSql());
-    }
-
-    public function testJoinLateralWithPrefix()
-    {
-        $builder = $this->getMySqlBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $builder->getGrammar()->setTablePrefix('prefix_');
-        $builder->from('users')->joinLateral('select * from `contacts` where `contracts`.`user_id` = `users`.`id`', 'sub');
-        $this->assertSame('select * from `prefix_users` inner join lateral (select * from `contacts` where `contracts`.`user_id` = `users`.`id`) as `prefix_sub` on true', $builder->toSql());
-    }
-
-    public function testLeftJoinLateral()
-    {
-        $builder = $this->getMySqlBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-
-        $sub = $this->getMySqlBuilder();
-        $sub->getConnection()->shouldReceive('getDatabaseName');
-
-        $builder->from('users')->leftJoinLateral($sub->from('contacts')->whereColumn('contracts.user_id', 'users.id'), 'sub');
-        $this->assertSame('select * from `users` left join lateral (select * from `contacts` where `contracts`.`user_id` = `users`.`id`) as `sub` on true', $builder->toSql());
-
-        $this->expectException(InvalidArgumentException::class);
-        $builder = $this->getBuilder();
-        $builder->from('users')->leftJoinLateral(['foo'], 'sub');
-    }
-
-    public function testLeftJoinLateralSqlServer()
-    {
-        $builder = $this->getSqlServerBuilder();
-        $builder->getConnection()->shouldReceive('getDatabaseName');
-        $builder->from('users')->leftJoinLateral(function ($q) {
-            $q->from('contacts')->whereColumn('contracts.user_id', 'users.id');
-        }, 'sub');
-        $this->assertSame('select * from [users] outer apply (select * from [contacts] where [contracts].[user_id] = [users].[id]) as [sub]', $builder->toSql());
-    }
-
     public function testRawExpressionsInSelect()
     {
         $builder = $this->getBuilder();
diff --git a/tests/Integration/Database/QueryBuilderTest.php b/tests/Integration/Database/QueryBuilderTest.php
index c07ef606142d..5d767d33fd5e 100644
--- a/tests/Integration/Database/QueryBuilderTest.php
+++ b/tests/Integration/Database/QueryBuilderTest.php
@@ -416,30 +416,27 @@ public function testChunkMap()
         $this->assertSame('Bar Post', $results[1]);
         $this->assertCount(3, DB::getQueryLog());
     }
-
-
-    #[DataProvider('pluckProvider')]
-    public function testPluck(string $pluckFn): void
+    public function testPluck(): void
     {
         // Test SELECT override, since pluck will take the first column.
         $this->assertSame([
             'Foo Post',
             'Bar Post',
-        ], DB::table('posts')->select(['content', 'id', 'title'])->$pluckFn('title')->toArray());
+        ], DB::table('posts')->select(['content', 'id', 'title'])->pluck('title')->toArray());
 
         // Test without SELECT override.
         $this->assertSame([
             'Foo Post',
             'Bar Post',
-        ], DB::table('posts')->$pluckFn('title')->toArray());
+        ], DB::table('posts')->pluck('title')->toArray());
 
         // Test specific key.
         $this->assertSame([
             1 => 'Foo Post',
             2 => 'Bar Post',
-        ], DB::table('posts')->$pluckFn('title', 'id')->toArray());
+        ], DB::table('posts')->pluck('title', 'id')->toArray());
 
-        $results = DB::table('posts')->$pluckFn('title', 'created_at');
+        $results = DB::table('posts')->pluck('title', 'created_at');
 
         // Test timestamps (truncates RDBMS differences).
         $this->assertSame([
@@ -454,7 +451,7 @@ public function testPluck(string $pluckFn): void
         // Test duplicate keys (a match will override a previous match).
         $this->assertSame([
             'Lorem Ipsum.' => 'Bar Post',
-        ], DB::table('posts')->$pluckFn('title', 'content')->toArray());
+        ], DB::table('posts')->pluck('title', 'content')->toArray());
 
         // Test null and empty string as key.
         $this->assertSame([
@@ -462,16 +459,14 @@ public function testPluck(string $pluckFn): void
             'entertainment' => 'Lorem Ipsum c.',
             null => 'Lorem Ipsum d.',
             '' => 'Lorem Ipsum e.',
-        ],  DB::table('comments')->$pluckFn('content', 'tag')->toArray());
+        ],  DB::table('comments')->pluck('content', 'tag')->toArray());
 
         // Test null and numeric as key.
         $this->assertSame([
             1 => 'Lorem Ipsum a.',
             0 => 'Lorem Ipsum b.',
             null => 'Lorem Ipsum e.',
-        ],  DB::table('comments')->$pluckFn('content', 'votes')->toArray());
-
-
+        ],  DB::table('comments')->pluck('content', 'votes')->toArray());
 
         if ($this->driver !== 'sqlsrv') {
             // Skip test for MS SQL Server since integers are returned as strings unless
@@ -484,25 +479,14 @@ public function testPluck(string $pluckFn): void
                 'Lorem Ipsum c.' => null,
                 'Lorem Ipsum d.' => null,
                 'Lorem Ipsum e.' => null,
-            ],  DB::table('comments')->$pluckFn('votes', 'content')->toArray());
+            ],  DB::table('comments')->pluck('votes', 'content')->toArray());
         }
-    }
 
-    public static function pluckProvider(): array
-    {
-        return [
-            ['pluck'],
-            ['pluckPDO'],
-        ];
-    }
-
-    public function testPluckPDORawExpressions(): void
-    {
         // Test custom query calculations.
         $this->assertSame([
             2 => 'FOO POST',
             4 => 'BAR POST',
-        ], DB::table('posts')->pluckPDO(
+        ], DB::table('posts')->pluck(
             DB::raw('UPPER(title)'),
             DB::raw('2 * id')
         )->toArray());