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
Fixed #35350 -- Fixed save() with pk set on models with GeneratedFields. #18058
Conversation
non_pks_non_generated = [ | ||
f | ||
for f in meta.local_concrete_fields | ||
if not f.primary_key and not f.generated | ||
] |
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 doesn't have to done here as this is meant as a non-invasive backport but since non_pks_non_generated
is only used for containment checks and doesn't need to preserve ordering it might be a good candidate to use a set
instead of a list
.
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.
It could also be cached up on Options
, it doesn’t need regenerating on every save()
call.
Note that I have just finished testing this against the test project from @matthewhegarty (thank you for proving that ⭐) and this works for me there too. 👍 |
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.
Looks great, thank you! 🌟
Thanks Matt Hegarty for the report and Simon Charette and Natalia Bidart for the reviews. Regression in f333e35.
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!
Thanks Matt Hegarty for the report.
Regression in f333e35.
Trac ticket number
ticket-35350
Checklist
main
branch.