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

Ensure mtime update is triggered for Django #2935

Merged
merged 1 commit into from
May 28, 2019

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented May 27, 2019

Fixes #2934

The ModelWrapper utility class ensures that a database model instance
is automatically saved if a model field is updated and the instance is
already stored. This prevents the implementation from having to call
save manually every time a field is updated. The Django implementation
uses the update_fields keyword of the save method, to update only
the field affected. However, this circumvents the auto_now of the
mtime field. This bug is currently not visible, because in the model
wrapper currently also always updates the node version after a model
field is updated of a stored instance. This, however, uses a normal
save and so does properly update the mtime. Once this updating of
the node version would have been removed, this bug will be revealed.

The `ModelWrapper` utility class ensures that a database model instance
is automatically saved if a model field is updated and the instance is
already stored. This prevents the implementation from having to call
`save` manually everytime a field is updated. The Django implementation
uses the `update_fields` keyword of the `save` method, to update only
the field affected. However, this circumvents the `auto_now` of the
`mtime` field. This bug is currently not visible, because in the model
wrapper currently also always updates the node version after a model
field is updated of a stored instance. This, however, uses a normal
`save` and so does properly update the `mtime`. Once this updating of
the node version would have been removed, this bug will be revealed.
@sphuber sphuber requested a review from giovannipizzi May 27, 2019 18:33
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 72.697% when pulling 56480e0 on sphuber:fix_2856_mtime_not_triggered into fbfabe8 on aiidateam:develop.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 72.697% when pulling 56480e0 on sphuber:fix_2856_mtime_not_triggered into fbfabe8 on aiidateam:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 72.697% when pulling 56480e0 on sphuber:fix_2856_mtime_not_triggered into fbfabe8 on aiidateam:develop.

@sphuber sphuber merged commit 9b5c015 into aiidateam:develop May 28, 2019
@sphuber sphuber deleted the fix_2856_mtime_not_triggered branch May 28, 2019 06:47
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.

Field Node.mtime only triggered by accident for django
3 participants