Skip to content

Commit

Permalink
Revert "[10.x] Improve numeric comparison for custom casts" (#49702)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Jan 16, 2024
1 parent 8d4eaeb commit 7cbdae5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2101,7 +2101,7 @@ public function originalIsEquivalent($key)
}

return is_numeric($attribute) && is_numeric($original)
&& BigDecimal::of($attribute)->isEqualTo($original);
&& strcmp((string) $attribute, (string) $original) === 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,33 +169,6 @@ public function testDeviableCasts()
$this->assertSame((new Decimal('320.988'))->getValue(), $model->price->getValue());
}

public function testDirtyOnCustomNumericCasts()
{
$model = new TestEloquentModelWithCustomCast;
$model->price = '123.00';
$model->save();

$this->assertFalse($model->isDirty());

$model->price = '123.00';
$this->assertFalse($model->isDirty('price'));

$model->price = '123.0';
$this->assertFalse($model->isDirty('price'));

$model->price = '123';
$this->assertFalse($model->isDirty('price'));

$model->price = '00123.00';
$this->assertFalse($model->isDirty('price'));

$model->price = '123.4000';
$this->assertTrue($model->isDirty('price'));

$model->price = '123.0004';
$this->assertTrue($model->isDirty('price'));
}

public function testSerializableCasts()
{
$model = new TestEloquentModelWithCustomCast;
Expand Down

0 comments on commit 7cbdae5

Please sign in to comment.