-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Having a null updated_at
column throws an error when updating model
#2533
Comments
I'll try to get a PR up for this on Monday morning. |
Hi can you try to add this dates in Model with
|
@puuble that's not what I'm talking about. I don't mean having a nullable date column. That doesn't cause problems. I'm talking about not having an I updated my description to make it clearer. |
Actually, this looks like it was fixed in 2ea1a7c which doesn't seem to have been included in recent releases. I guess it'll be fine with versions that support Laravel 10. |
Description:
When
UPDATED_AT
(orCREATED_AT
) is set tonull
in the model, a warning is thrown when updating the model.Setting
UPDATED_AT
tonull
is a common way to allow for acreated_at
column, but notupdated_at
.For example:
https://github.com/laravel/framework/blob/10.x/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php#L62-L70
Here, Laravel checks that the updated_at column isn't null before setting it.
However:
https://github.com/jenssegers/laravel-mongodb/blob/v3.9.5/src/Eloquent/Model.php#L226-L230
Here, we get all the dates columns, which could include nulls. Then, calling
Str::contains($key, '.')
results in a deprecation warning:Steps to reproduce
UPDATED_AT
tonull
in a model class.$model->update([/* ... */]);
Expected behaviour
null should be skipped
Actual behaviour
Warning
Possible fix
The text was updated successfully, but these errors were encountered: