-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.8] Sync method return wrong updated record and event with Pivot class #28150
Comments
Probably caused by #27571. /cc @ralphschindler |
@link08 regarding "Problem 1", when you run sync() with a Pivot class that has timestamps, aren't you at least updating the timestamps? Hence it listed in the update? Regarding "problem 2", what if you hooked into the updating() event and look for the attribute there? I will dig more soon. |
Question 1No, the updated_at column is not updated. Checking if in Laravel 5.7 it works correctly I found another strange thing. Adding
Question 2Yes, the method
Test codeI've created a public repository with my test code: The sample code is inside: |
Problem appears to be in that sync does not check if the update is needed. No check on additional fields, only relational fields. It will check what needs to be deleted and added. Everything else is updated.
|
InteractsWithPivotTable::sync():91
Takes only related id-s, not full records. |
Prs for this were merged. |
Description:
After the update from Laravel 5.7 to Laravel 5.8 the sync() method with pivot class doesn't return the correct values.
Problem 1
If I try to read the response from the
->sync()
method, inside the 'updated' value there are all the values, even if there wasn't any change.Problem 2
I updated to Laravel 5.8 to use the Observer with the pivot class but the updated event is triggered every time and I can't get the original value of a pivot attribute with the method
->getOriginal()
Steps To Reproduce:
Models:
Sample code:
with Laravel 5.7 the last var_dump return:
Observer:
The text was updated successfully, but these errors were encountered: