Skip to content

Commit

Permalink
revert change to float casting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 24, 2020
1 parent 3e7e9b2 commit bf3cb6f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
5 changes: 0 additions & 5 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1178,11 +1178,6 @@ public function originalIsEquivalent($key, $current)
} elseif ($this->hasCast($key, ['object', 'collection'])) {
return $this->castAttribute($key, $current) ==
$this->castAttribute($key, $original);
} elseif ($this->hasCast($key, ['real', 'float', 'double'])) {
return bccomp(
$this->castAttribute($key, $current),
$this->castAttribute($key, $original)
) === 0;
} elseif ($this->hasCast($key)) {
return $this->castAttribute($key, $current) ===
$this->castAttribute($key, $original);
Expand Down
14 changes: 0 additions & 14 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,6 @@ public function testCleanAttributes()
$this->assertFalse($model->isClean(['foo', 'bar']));
}

public function testCleanWhenFloatUpdateAttribute()
{
$original = -16.666347;
$new = 20.1 - 36.766347;

$this->assertFalse($original === $new);
$this->assertSame(0, bccomp($original, $new));

$model = new EloquentModelStub(['castedFloat' => $original]);
$model->syncOriginal();
$this->assertTrue($model->originalIsEquivalent('castedFloat', $new));
}

public function testCalculatedAttributes()
{
$model = new EloquentModelStub;
Expand Down Expand Up @@ -2005,7 +1992,6 @@ class EloquentModelStub extends Model
protected $table = 'stub';
protected $guarded = [];
protected $morph_to_stub_type = EloquentModelSaveStub::class;
protected $casts = ['castedFloat' => 'float'];

public function getListItemsAttribute($value)
{
Expand Down

0 comments on commit bf3cb6f

Please sign in to comment.