Skip to content

Commit

Permalink
Fix SQLSTATE[22003]: Numeric value out of range error (#89)
Browse files Browse the repository at this point in the history
* Fix `SQLSTATE[22003]: Numeric value out of range` error

* Fix `DecimalResolverTest` for fake
  • Loading branch information
cable8mm authored Jan 6, 2025
1 parent ef02ff2 commit c524228
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Resolvers/DecimalResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Resolvers/DecimalResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c524228

Please sign in to comment.