From 7c8989643d76a4fb14950164f7ee314ce6be2fa1 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 3 Jul 2020 01:00:44 +0100 Subject: [PATCH] Added float comparison null checks --- src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index b6c080a7f2e5..c5fa43a60955 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -1179,6 +1179,10 @@ public function originalIsEquivalent($key, $current) return $this->castAttribute($key, $current) == $this->castAttribute($key, $original); } elseif ($this->hasCast($key, ['real', 'float', 'double'])) { + if (($current === null && $original !== null) || ($current !== null && $original === null)) { + return false; + } + return abs($this->castAttribute($key, $current) - $this->castAttribute($key, $original)) < PHP_FLOAT_EPSILON * 4; } elseif ($this->hasCast($key)) { return $this->castAttribute($key, $current) ===