[6.x] Fix originalIsEquivalent with floats#33259
Conversation
originalIsEquivalent with for floats
originalIsEquivalent with for floatsoriginalIsEquivalent with floats
| return $this->castAttribute($key, $current) == | ||
| $this->castAttribute($key, $original); | ||
| } elseif ($this->hasCast($key, 'float')) { | ||
| return bccomp( |
There was a problem hiding this comment.
I think by using bccomp function, we need to require ext-bcmath into the composer.json file
There was a problem hiding this comment.
This project has a depency on: moontoast/math.
So therefore the existence of ext-bcmath is already checked: https://github.com/moontoast/math/blob/master/composer.json#L14
There was a problem hiding this comment.
@BassemN is correct though; that another dependency depends on something which is now ultimately a shared dependency is not enough.
This project has a depency on: moontoast/math.
It's only a suggested dependency of illuminate/support.
However you can use illuminate/database independent of Laravel (which I'm doing).
Therefore I believe that the dependency belongs into:
src/Illuminate/Database/composer.json
as well as intocomposer.json
Because it's now a hard requirement for Laravel 6.
There was a problem hiding this comment.
We cannot add that dependency. I'd suggest we change this code to avoid using that function.
According to the PHP Docs:
https://www.php.net/manual/en/language.types.float.php
You shouldn't compare two floats directly for equality.
This only manifests when you cast to a float, otherwise you'll fall into the:
Which works for floats fine.