From b2771c5b7cd4b3358beb3014c0ae3fabefd76f4c Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Mon, 6 Jan 2025 13:28:52 +0900 Subject: [PATCH 1/2] Fix `SQLSTATE[22003]: Numeric value out of range` error --- src/Resolvers/DecimalResolver.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Resolvers/DecimalResolver.php b/src/Resolvers/DecimalResolver.php index 8ae66f5..dfba790 100644 --- a/src/Resolvers/DecimalResolver.php +++ b/src/Resolvers/DecimalResolver.php @@ -20,7 +20,11 @@ class DecimalResolver extends Resolver { public function fake(): string { - return '\''.$this->column->field.'\' => fake()->randomFloat(2, 0, 10000),'; + $bracket = Bracket::of($this->column->bracket)->escape(); + + $bracket = empty($bracket) ? '' : ', '.$bracket; + + return '\''.$this->column->field.'\' => fake()->randomFloat('.$bracket.'),'; } public function migration(): string From 96be7ee5ccc755976fca8fc63f92b4dbd2ea4707 Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Mon, 6 Jan 2025 13:30:48 +0900 Subject: [PATCH 2/2] Fix `DecimalResolverTest` for fake --- tests/Unit/Resolvers/DecimalResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/Resolvers/DecimalResolverTest.php b/tests/Unit/Resolvers/DecimalResolverTest.php index 6203e41..c21c4e0 100644 --- a/tests/Unit/Resolvers/DecimalResolverTest.php +++ b/tests/Unit/Resolvers/DecimalResolverTest.php @@ -42,7 +42,7 @@ public function test_fake_method_can_working_well(): void { $resolver = new DecimalResolver($this->column); - $this->assertEquals('\''.$resolver->field.'\' => fake()->randomFloat(2, 0, 10000),', $resolver->fake()); + $this->assertEquals('\''.$resolver->field.'\' => fake()->randomFloat(),', $resolver->fake()); } public function test_migration_method_can_working_well(): void