fix: should not skip auto now fields but assign with specified value#520
Merged
amureki merged 1 commit intomodel-bakers:mainfrom Feb 26, 2025
Merged
fix: should not skip auto now fields but assign with specified value#520amureki merged 1 commit intomodel-bakers:mainfrom
amureki merged 1 commit intomodel-bakers:mainfrom
Conversation
765364b to
3353a8c
Compare
There was a problem hiding this comment.
PR Overview
This PR fixes a regression that prevented assigning specified values to auto now fields by modifying the field handling in Baker. Key changes include:
- Removing the automatic skipping of auto now fields in _skip_field.
- Updating _handle_auto_now to perform a forced update via the model’s manager and then manually assign the specified values.
- Adding new test cases for auto now fields in both recipes and baker tests, and updating the CHANGELOG accordingly.
Reviewed Changes
| File | Description |
|---|---|
| tests/test_recipes.py | Added TestAutoNowFields with two test cases using different value generators. |
| model_bakery/baker.py | Removed skip for auto now fields in _skip_field and revised _handle_auto_now to update and assign fields. |
| tests/test_baker.py | Extended tests to assert that auto now fields remain unchanged after refresh. |
| CHANGELOG.md | Documented the fix for the regression regarding auto now field updates. |
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
amureki
approved these changes
Feb 26, 2025
Member
amureki
left a comment
There was a problem hiding this comment.
Good change!
This indeed feels like a better solution, thanks for the fix @mattwang44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the change
Fix #519, which is a regression introduced in #507.
_skip_field(). Instead, assign the specified value to the resulting instance.PR Checklist