From 2298bc341f3edcf95aa54ac03687b763414dce76 Mon Sep 17 00:00:00 2001 From: Apos Spanos <5887954+apspan@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:45:10 +0300 Subject: [PATCH] [10.x] Laravel 10x optional withSize for hasTable (#50888) * make withsize optional for SQLiteBuilder's getTables * refactoring SQLiteBuilder::getTables Signed-off-by: Apos Spanos * correcting SQLiteBuilder::getTables Signed-off-by: Apos Spanos --------- Signed-off-by: Apos Spanos --- src/Illuminate/Database/Schema/Builder.php | 2 +- src/Illuminate/Database/Schema/SQLiteBuilder.php | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Illuminate/Database/Schema/Builder.php b/src/Illuminate/Database/Schema/Builder.php index 51b97f690618..4a8839442951 100755 --- a/src/Illuminate/Database/Schema/Builder.php +++ b/src/Illuminate/Database/Schema/Builder.php @@ -162,7 +162,7 @@ public function hasTable($table) { $table = $this->connection->getTablePrefix().$table; - foreach ($this->getTables() as $value) { + foreach ($this->getTables(false) as $value) { if (strtolower($table) === strtolower($value['name'])) { return true; } diff --git a/src/Illuminate/Database/Schema/SQLiteBuilder.php b/src/Illuminate/Database/Schema/SQLiteBuilder.php index 8ae272d767b6..e7d6e8c905eb 100644 --- a/src/Illuminate/Database/Schema/SQLiteBuilder.php +++ b/src/Illuminate/Database/Schema/SQLiteBuilder.php @@ -34,16 +34,17 @@ public function dropDatabaseIfExists($name) /** * Get the tables for the database. * + * @param bool $withSize * @return array */ - public function getTables() + public function getTables($withSize = true) { - $withSize = false; - - try { - $withSize = $this->connection->scalar($this->grammar->compileDbstatExists()); - } catch (QueryException $e) { - // + if ($withSize) { + try { + $withSize = $this->connection->scalar($this->grammar->compileDbstatExists()); + } catch (QueryException $e) { + $withSize = false; + } } return $this->connection->getPostProcessor()->processTables(