From 3c5bdfd9f0724b1c0fefbf9d2876a4196199b3d7 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Mon, 7 Nov 2022 14:44:03 +0000 Subject: [PATCH] Handle SQLite without ENABLE_DBSTAT_VTAB enabled. Fixes #44860 (#44867) --- .../Database/Console/DatabaseInspectionCommand.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Database/Console/DatabaseInspectionCommand.php b/src/Illuminate/Database/Console/DatabaseInspectionCommand.php index 80a59adeac18..e3391a09e6d4 100644 --- a/src/Illuminate/Database/Console/DatabaseInspectionCommand.php +++ b/src/Illuminate/Database/Console/DatabaseInspectionCommand.php @@ -7,6 +7,7 @@ use Illuminate\Database\ConnectionInterface; use Illuminate\Database\MySqlConnection; use Illuminate\Database\PostgresConnection; +use Illuminate\Database\QueryException; use Illuminate\Database\SQLiteConnection; use Illuminate\Database\SqlServerConnection; use Illuminate\Support\Arr; @@ -151,11 +152,15 @@ protected function getPostgresTableSize(ConnectionInterface $connection, string */ protected function getSqliteTableSize(ConnectionInterface $connection, string $table) { - $result = $connection->selectOne('SELECT SUM(pgsize) AS size FROM dbstat WHERE name=?', [ - $table, - ]); + try { + $result = $connection->selectOne('SELECT SUM(pgsize) AS size FROM dbstat WHERE name=?', [ + $table, + ]); - return Arr::wrap((array) $result)['size']; + return Arr::wrap((array) $result)['size']; + } catch (QueryException $e) { + return null; + } } /**