-
Notifications
You must be signed in to change notification settings - Fork 130
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
Fix tracking subclasses with additional fields #237
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Thoughts on below?
lib/mongoid/history/options.rb
Outdated
@@ -14,44 +14,44 @@ def scope | |||
|
|||
def prepared | |||
@prepared ||= begin | |||
@prepared = options.dup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks strange. Change it to:
return if @prepared
@prepared = ...
Generally I am a bit concerned that we are now making assignment of prepared
and modifying it all over the place. Is there a way to fix the issue without doing that change and keep gathering settings and returning modified version from functions, then calling merge
on the results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really feel like the library took a turn down a wrong path with the linked commit and I'm just trying to make the best of it. @options
was assigned and modified all over the place already, I just switched it so the original options could be retrieved. Another direction I considered was having Options keep and expose the original_options
and leave it modifying @options
and using @prepared
in the same way it does now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like keeping original_options
, feels cleaner, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I am fine with the code as is. LMK when you want to merge (on green).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an uglier changeset in the commit, but it feels a little cleaner to me to in the end to keep the mutation done by prepared
isolated to @prepared
instead of @options
.
The Travis build is green, but neither time has it updated the GitHub status. 😕
LGTM, merged |
If you have subclasses with their own fields, none of those fields are being tracked because the options will only look at the parent class' fields. For example:
This worked prior to this commit: 774dd0d