You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems recent changes to fix originalIsEquivalent for floats in \Illuminate\Database\Eloquent\Concerns\HasAttributes have broken the ability to change null to 0 with a float attribute.
That is, if you do $model->attr = 0 then $model->save(), the change is not saved to the database, because originalIsEquivalent('attr') returns true (so $model->getDirty() returns []).
I think it started with #33259, but the most recent version seems to be #33322.
PS: The first two tests in originalIsEquivalent() are:
I'm wondering if you could simply change the second of these to elseif (is_null($attribute) || is_null($original))? Is there any case in which the original can be null and the new value non-null, but they are considered equivalent?
PPS: I'm a very part-time volunteer dev - I've almost never done this sort of thing, so hope I'm doing it right...
Steps To Reproduce:
Here's the result of my tinkering (some irrelevant output lines omitted):
Description:
It seems recent changes to fix
originalIsEquivalent
for floats in\Illuminate\Database\Eloquent\Concerns\HasAttributes
have broken the ability to changenull
to0
with a float attribute.That is, if you do
$model->attr = 0
then$model->save()
, the change is not saved to the database, becauseoriginalIsEquivalent('attr')
returnstrue
(so$model->getDirty()
returns[]
).I think it started with #33259, but the most recent version seems to be #33322.
PS: The first two tests in
originalIsEquivalent()
are:I'm wondering if you could simply change the second of these to
elseif (is_null($attribute) || is_null($original))
? Is there any case in which the original can be null and the new value non-null, but they are considered equivalent?PPS: I'm a very part-time volunteer dev - I've almost never done this sort of thing, so hope I'm doing it right...
Steps To Reproduce:
Here's the result of my tinkering (some irrelevant output lines omitted):
And here's the same test run on an earlier version (7.12) of the framework:
The text was updated successfully, but these errors were encountered: