Mongoid 7.x runs callback even when no changes for update? #5411
Unanswered
sachiotomita
asked this question in
Q&A
Replies: 2 comments
-
When you enable autosaving, you are asking for the child models to be taken through the save process. There may not be any changes written to the database but Mongoid still has to go through all of the models and attempt to save them. |
Beta Was this translation helpful? Give feedback.
0 replies
-
AR works the same way:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm upgrading Mongoid 6 to 7 (on existing Rails app). due to rails upgrade..
As I searched, Mongoid 7 has breaking change on association(refactoring).
When upgrade to 7.x
my rails app is calling update callbacks(before_update/after_update, etc.) every time related model's save/create,
even when no changes to update,
if the association is
autosave: true
it can cause many unexpected behaviors on callbacks process.
why? and how to avoid this many unwanted callbacks?
Image should be immutable, but update callback is called. when create().
backtrace (from update on controller, to callback)
https://github.com/mongodb/mongoid/blob/master/lib/mongoid/persistable/updatable.rb#L133
https://github.com/mongodb/mongoid/blob/master/lib/mongoid/interceptable.rb#L9
Beta Was this translation helpful? Give feedback.
All reactions