From 87dfc3e4134af0d49b1c6fd9f48dcdea68a2823c Mon Sep 17 00:00:00 2001 From: Apos Spanos Date: Sun, 31 Mar 2024 13:56:30 +0100 Subject: [PATCH 1/3] make withsize optional for SQLiteBuilder's getTables --- src/Illuminate/Database/Schema/Builder.php | 2 +- .../Database/Schema/SQLiteBuilder.php | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 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..5f32e3a93a28 100644 --- a/src/Illuminate/Database/Schema/SQLiteBuilder.php +++ b/src/Illuminate/Database/Schema/SQLiteBuilder.php @@ -36,15 +36,18 @@ public function dropDatabaseIfExists($name) * * @return array */ - public function getTables() + public function getTables(?bool $forceWithSize = null) { - $withSize = false; - - try { - $withSize = $this->connection->scalar($this->grammar->compileDbstatExists()); - } catch (QueryException $e) { - // - } + $withSize = match ($forceWithSize) { + true, false => $forceWithSize, + default => function () { + try { + return $this->connection->scalar($this->grammar->compileDbstatExists()); + } catch (QueryException $e) { + return false; + } + }, + }; return $this->connection->getPostProcessor()->processTables( $this->connection->selectFromWriteConnection($this->grammar->compileTables($withSize)) From 6a37d6f692542a8933e2014371284217164977d8 Mon Sep 17 00:00:00 2001 From: Apos Spanos Date: Sun, 31 Mar 2024 16:14:41 +0100 Subject: [PATCH 2/3] refactoring SQLiteBuilder::getTables Signed-off-by: Apos Spanos --- src/Illuminate/Database/Schema/SQLiteBuilder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Schema/SQLiteBuilder.php b/src/Illuminate/Database/Schema/SQLiteBuilder.php index 5f32e3a93a28..1471986e0c3c 100644 --- a/src/Illuminate/Database/Schema/SQLiteBuilder.php +++ b/src/Illuminate/Database/Schema/SQLiteBuilder.php @@ -34,12 +34,13 @@ public function dropDatabaseIfExists($name) /** * Get the tables for the database. * + * @param bool $withSize * @return array */ - public function getTables(?bool $forceWithSize = null) + public function getTables($withSize = true) { - $withSize = match ($forceWithSize) { - true, false => $forceWithSize, + $withSize = match ($withSize) { + false => false, default => function () { try { return $this->connection->scalar($this->grammar->compileDbstatExists()); From e73546db08f73e694bcf0aa0464325ca11945d30 Mon Sep 17 00:00:00 2001 From: Apos Spanos Date: Sun, 31 Mar 2024 16:34:09 +0100 Subject: [PATCH 3/3] correcting SQLiteBuilder::getTables Signed-off-by: Apos Spanos --- .../Database/Schema/SQLiteBuilder.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Illuminate/Database/Schema/SQLiteBuilder.php b/src/Illuminate/Database/Schema/SQLiteBuilder.php index 1471986e0c3c..e7d6e8c905eb 100644 --- a/src/Illuminate/Database/Schema/SQLiteBuilder.php +++ b/src/Illuminate/Database/Schema/SQLiteBuilder.php @@ -39,16 +39,13 @@ public function dropDatabaseIfExists($name) */ public function getTables($withSize = true) { - $withSize = match ($withSize) { - false => false, - default => function () { - try { - return $this->connection->scalar($this->grammar->compileDbstatExists()); - } catch (QueryException $e) { - return false; - } - }, - }; + if ($withSize) { + try { + $withSize = $this->connection->scalar($this->grammar->compileDbstatExists()); + } catch (QueryException $e) { + $withSize = false; + } + } return $this->connection->getPostProcessor()->processTables( $this->connection->selectFromWriteConnection($this->grammar->compileTables($withSize))