Skip to content
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

MONGOID-5104 Add AR-style dirty attributes #5092

Merged
merged 3 commits into from
Oct 19, 2021

Conversation

comandeo
Copy link
Contributor

@comandeo comandeo commented Oct 13, 2021

Dirty data are now cleared and changes moved previous_changes immediately after a document is persisted in MongoDB. It means that old attribute values are available in before_ callbacks, and updated attribute values are available in after_ callbacks.

@comandeo comandeo marked this pull request as draft October 13, 2021 09:40
@comandeo
Copy link
Contributor Author

@comandeo comandeo changed the title 5104 MONGOID-5104 Add AR-style dirty attributes Oct 18, 2021
@comandeo comandeo marked this pull request as ready for review October 18, 2021 09:16
@comandeo comandeo requested a review from p-mongo October 18, 2021 09:48
Copy link
Contributor

@p-mongo p-mongo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't understand the changes here, can you please add a one sentence summary to the description and the resulting merge commit message should anyone happen to be debugging something in the future and be looking at this commit as a possible cause?

@comandeo comandeo merged commit 0787a31 into mongodb:master Oct 19, 2021
@comandeo comandeo deleted the 5104-fix-attribute_was branch October 19, 2021 10:27
@johnnyshields
Copy link
Contributor

@p-mongo @comandeo please see this follow-up ticket: https://jira.mongodb.org/browse/MONGOID-5217

carlosantoniodasilva added a commit to heartcombo/devise that referenced this pull request Mar 31, 2023
It appears Mongoid 8.0+ slightly [changed dirty tracking] behavior to
more closely match Active Model/Record, however they haven't yet
introduced the [new methods] that match the latest API, that seems to be
coming on Mongoid 8.1 only.

The changes here try to accommodate for that by determining which
"attribute_changed?" method to call depending on whether the
"*_previously_*" version exists. Newer versions of AR (5.1+) will
continue to use the new API / methods, whereas previous versions and
Mongoid 8.0+ will use these tweaked versions. No behavior should change
for AR, but it will hopefully support Mongoid 8.0+ now.

[changed dirty tracking]
mongodb/mongoid#5092

[new methods]
mongodb/mongoid#5440
carlosantoniodasilva added a commit to heartcombo/devise that referenced this pull request Oct 13, 2023
It appears Mongoid 8.0+ slightly [changed dirty tracking] behavior to
more closely match Active Model/Record, however they haven't yet
introduced the [new methods] that match the latest API, that seems to be
coming on Mongoid 8.1 only.

The changes here try to accommodate for that by determining which
"attribute_changed?" method to call depending on whether the
"*_previously_*" version exists. Newer versions of AR (5.1+) will
continue to use the new API / methods, whereas previous versions and
Mongoid 8.0+ will use these tweaked versions. No behavior should change
for AR, but it will hopefully support Mongoid 8.0+ now.

[changed dirty tracking]
mongodb/mongoid#5092

[new methods]
mongodb/mongoid#5440
carlosantoniodasilva added a commit to heartcombo/devise that referenced this pull request Apr 9, 2024
It appears Mongoid 8.0+ slightly [changed dirty tracking] behavior to
more closely match Active Model/Record, however they haven't yet
introduced the [new methods] that match the latest API, that seems to be
coming on Mongoid 8.1 only.

The changes here try to accommodate for that by determining which
"attribute_changed?" method to call depending on whether the
"*_previously_*" version exists. Newer versions of AR (5.1+) will
continue to use the new API / methods, whereas previous versions and
Mongoid 8.0+ will use these tweaked versions. No behavior should change
for AR, but it will hopefully support Mongoid 8.0+ now.

[changed dirty tracking]
mongodb/mongoid#5092

[new methods]
mongodb/mongoid#5440
carlosantoniodasilva added a commit to heartcombo/devise that referenced this pull request Apr 10, 2024
It appears Mongoid 8.0+ slightly [changed dirty tracking] behavior to
more closely match Active Model/Record, however they haven't yet
introduced the [new methods] that match the latest API, that seems to be
coming on Mongoid 8.1 only.

The changes here try to accommodate for that by determining which
"attribute_changed?" method to call depending on whether the
"*_previously_*" version exists. Newer versions of AR (5.1+) will
continue to use the new API / methods, whereas previous versions and
Mongoid 8.0+ will use these tweaked versions. No behavior should change
for AR, but it will hopefully support Mongoid 8.0+ now.

[changed dirty tracking]
mongodb/mongoid#5092

[new methods]
mongodb/mongoid#5440
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants