Skip to content

Commit a22ad1f

Browse files
Added float comparison null checks (#33421)
1 parent 1116adb commit a22ad1f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,10 @@ public function originalIsEquivalent($key, $current)
11791179
return $this->castAttribute($key, $current) ==
11801180
$this->castAttribute($key, $original);
11811181
} elseif ($this->hasCast($key, ['real', 'float', 'double'])) {
1182+
if (($current === null && $original !== null) || ($current !== null && $original === null)) {
1183+
return false;
1184+
}
1185+
11821186
return abs($this->castAttribute($key, $current) - $this->castAttribute($key, $original)) < PHP_FLOAT_EPSILON * 4;
11831187
} elseif ($this->hasCast($key)) {
11841188
return $this->castAttribute($key, $current) ===

0 commit comments

Comments
 (0)