Update FileAttachment.objects.create_from_filediff to set needed fields.
Review Request #13532 — Created Feb. 12, 2024 and submitted
It turns out that having a FileAttachment for a diff that does not have
the review request set will cause the review UI instantiation to fail.
This change fixes thecreate_from_filediff
method to set the review
request and local site fields correctly based on the given FileDiff's
review request.
- Ran unit tests.
- Used this when automatically creating a diff file attachment in a
later change.
Summary | ID |
---|---|
03af6a5de80fa01c8dce9b878cb73e6cb6b5b899 |
Description | From | Last Updated |
---|---|---|
'django.core.exceptions.ObjectDoesNotExist' imported but unused Column: 1 Error code: F401 |
reviewbot | |
By default, .set() will query for existing objects, compare to what's in there, remove any old ones, and then set … |
chipx86 | |
This is missing a Version Added. |
chipx86 | |
Do we want to cache the None locally, or check again the next time this is called? I feel like … |
chipx86 |
- Commits:
-
Summary ID 8906fa362559a4e2659dabb912af4a1df87d2361 bf4481c4c5909a1308757c840cc173ead17c30ee
Checks run (2 succeeded)
-
-
By default,
.set()
will query for existing objects, compare to what's in there, remove any old ones, and then set new ones. That's minimum 2, max 3 queries.That can be reduced to a guaranteed 2 if we pass
clear=True
, which will just delete what's in there and replace it.However, we know this model is new and that we're adding to it for the first time, so we can avoid all that and just use
.add()
to get 1 query. -
-
Do we want to cache the
None
locally, or check again the next time this is called? I feel like the former avoids unexpected behavior, since this is only during the lifetime of a request.In either case, we should document this.