From 01b9fa59e97c9e3731d57fb07fbf893a8ab34984 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 16 Jan 2024 10:47:55 +0100 Subject: [PATCH] Revert "[10.x] Improve numeric comparison for custom casts" --- .../Eloquent/Concerns/HasAttributes.php | 2 +- ...DatabaseEloquentModelCustomCastingTest.php | 27 ------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index 029d45637c63..991f06434a5b 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -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; } /** diff --git a/tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php b/tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php index bfa3d533514b..8bbdb68c0271 100644 --- a/tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php +++ b/tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php @@ -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;