From fc98fcc932c70b9b5e60a437f6c719e8ca10d054 Mon Sep 17 00:00:00 2001 From: Adam Lee Date: Mon, 6 May 2024 15:34:12 +0100 Subject: [PATCH] fix: replaceJsonColumnsSqliteWorkaround make sure value is an array --- src/Concerns/InteractsWithDbSchema.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Concerns/InteractsWithDbSchema.php b/src/Concerns/InteractsWithDbSchema.php index f1d91b3..dcf75e2 100644 --- a/src/Concerns/InteractsWithDbSchema.php +++ b/src/Concerns/InteractsWithDbSchema.php @@ -20,7 +20,7 @@ protected function getAllTableNames(): Collection } /** - * @return \Illuminate\Support\Collection> + * @return \Illuminate\Support\Collection> */ protected function getTableColumns(string $table, bool $withProperties = false): Collection { @@ -36,7 +36,7 @@ protected function getTableColumns(string $table, bool $withProperties = false): /** * @param array $exclude - * @return \Illuminate\Support\Collection> + * @return \Illuminate\Support\Collection> */ protected function getTableColumnsForRelation(string $table, array $exclude = []): Collection { @@ -68,7 +68,7 @@ protected function isFieldNullable(array $fieldProperties): bool } /** - * @return Collection> + * @phpstan-ignore-next-line */ private function replaceJsonColumnsSqliteWorkaround(string $table): Collection { @@ -76,11 +76,12 @@ private function replaceJsonColumnsSqliteWorkaround(string $table): Collection return collect($results)->map(function ($column) use ($table) { $column_value = DB::table($table)->whereNotNull($column->name)->value($column->name); - if (Str::isJson($column_value)) { + + if (is_string($column_value) && is_array(json_decode($column_value, true))) { $column->type_name = $column->type = 'json'; } - return $column; + return (array) $column; }); } }