From eb7b696fd419779279f3582b5b148e112043ff71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=CC=88nther=20Debrauwer?= Date: Mon, 5 Feb 2024 15:39:35 +0100 Subject: [PATCH 1/2] Update Sushi.php --- src/Sushi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sushi.php b/src/Sushi.php index 0c9b941..0b72544 100644 --- a/src/Sushi.php +++ b/src/Sushi.php @@ -136,7 +136,7 @@ public function migrate() if (count($this->casts) > 0) { foreach ($rows as $row) { // If $casts are present, use Eloquent's "create" instead of a plain insert so they are used and applied... - static::forceCreate($row); + static::make()->setRawAttributes($row)->save(); } } else { foreach (array_chunk($rows, $this->getSushiInsertChunkSize()) ?? [] as $inserts) { From 23d8128c3635fef28ae3024268885fe2ac5a939d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=CC=88nther=20Debrauwer?= Date: Mon, 5 Feb 2024 15:42:57 +0100 Subject: [PATCH 2/2] Fix test --- tests/SushiTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/SushiTest.php b/tests/SushiTest.php index aad9b73..cc4f56e 100644 --- a/tests/SushiTest.php +++ b/tests/SushiTest.php @@ -393,7 +393,9 @@ class ModelWithCasts extends Model 'is_boolean' => 'boolean', ]; - protected $rows = [ - ['is_array' => [1, 2, 3], 'is_boolean' => true], - ]; + protected function getRows() { + return [ + ['is_array' => json_encode([1, 2, 3]), 'is_boolean' => true], + ]; + } }