-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Migration 0033 failed when empty placeholder objects were not present in the db #8339
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
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnhance migration 0033 by tightening the conditional in the forwards function to update placeholder associations only when an existing placeholder object is present, preventing failures on missing records. Class diagram for updated placeholder association logic in migration 0033classDiagram
class PlaceholderField {
+content_type_id
+object_id
+save()
}
class ContentType {
+pk
}
class Object {
+pk
}
PlaceholderField -- ContentType : content_type_id
PlaceholderField -- Object : object_id
Flow diagram for conditional update in migration 0033flowchart TD
A["Iterate over objects"] --> B["Check if placeholder object exists"]
B -- Yes --> C["Create new PlaceholderField with content_type_id and object_id"]
B -- No but obj_placeholder_field exists --> D["Update obj_placeholder_field with content_type_id and object_id"]
D --> E["Save obj_placeholder_field"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `cms/migrations/0033_placeholder_source_data_migration.py:42` </location>
<code_context>
object_id=obj.pk,
)
- else:
+ elif obj_placeholder_field:
obj_placeholder_field.content_type_id = cur_ct_obj.pk
obj_placeholder_field.object_id = obj.pk
</code_context>
<issue_to_address>
Consider whether the new elif branch could mask cases where obj_placeholder_field is falsy but not None.
Changing to 'elif obj_placeholder_field:' means the block only runs for truthy values. If valid cases exist where obj_placeholder_field is falsy, this logic may skip updates. Please verify that all necessary cases are still handled.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -39,7 +39,7 @@ def forwards(apps, schema_editor): | |||
content_type_id=cur_ct_obj.pk, | |||
object_id=obj.pk, | |||
) | |||
else: | |||
elif obj_placeholder_field: |
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.
question: Consider whether the new elif branch could mask cases where obj_placeholder_field is falsy but not None.
Changing to 'elif obj_placeholder_field:' means the block only runs for truthy values. If valid cases exist where obj_placeholder_field is falsy, this logic may skip updates. Please verify that all necessary cases are still handled.
👋 Hi there! Please remember to MERGE COMMIT pull requests from Do not SQUASH commits to preserve history for the changelog. |
…esent in the db
Description
Related resources
Checklist
main
Summary by Sourcery
Bug Fixes: