Django

Code

Ticket #3081 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] Fix deleting objects with generic relation

Reported by: Alex Dedul Assigned to: adrian
Milestone: Component: Database wrapper
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

When you have generic relation in a model and you do model_obj.delete() from generic related table deleted all records with object_id = model_obj.id - that is incorrect. Correct condition for deletion should be "object_id = model_obj.id AND content_type = content_type(model_obj)" (in pseudo code). Also this patch fixes deletion of a model with generic foreign key(i.e. model referenced by generic relation) - current behavior is to try to delete records from m2m generic relations, but there is no m2m tables created for generic relations so there is no need to delete anything in this case - this also fixes issues mentioned in #2749 with deletion of both records.

Attached patch fixes all these issues.

Attachments

genericrelation_delete.patch (3.0 kB) - added by Alex Dedul on 11/29/06 15:07:53.

Change History

11/29/06 15:07:53 changed by Alex Dedul

  • attachment genericrelation_delete.patch added.

12/06/06 00:41:49 changed by adrian

  • component changed from Core framework to Database wrapper.

01/25/07 05:36:09 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [4428]) Fixed #3215, #3081, #2749 -- Fixed problem with mistaken deletion of objects when a GenericRelation?? is involved. Thanks to Thomas Steinacher for helping to narrow down the problem (#3215), and Alex Dedul (#3081) for the starting point of a working patch.


Add/Change #3081 ([patch] Fix deleting objects with generic relation)




Change Properties
Action