Ticket #9308: 9308.diff
File 9308.diff, 1.8 KB (added by , 16 years ago) |
---|
-
django/db/models/query.py
1006 1006 update_query = sql.UpdateQuery(cls, connection) 1007 1007 for field, model in cls._meta.get_fields_with_model(): 1008 1008 if (field.rel and field.null and field.rel.to in seen_objs and 1009 filter(lambda f: f.column == field. column,1009 filter(lambda f: f.column == field.rel.get_related_field().column, 1010 1010 field.rel.to._meta.fields)): 1011 1011 if model: 1012 1012 sql.UpdateQuery(model, connection).clear_related(field, -
tests/modeltests/delete/models.py
168 168 >>> o.keys() 169 169 [<class 'modeltests.delete.models.F'>, <class 'modeltests.delete.models.E'>] 170 170 171 # Monkey-patch the UpdateQuery class to verify that E.f is actually nulled out first 172 >>> from django.db.models.sql import UpdateQuery 173 >>> def clear_related_wrapper(old_clr): 174 ... def _w(self, related_field, pk_list): 175 ... print related_field.name 176 ... return old_clr(self, related_field, pk_list) 177 ... return _w 178 >>> old_clear_related = UpdateQuery.clear_related 179 >>> UpdateQuery.clear_related = clear_related_wrapper(UpdateQuery.clear_related) 171 180 >>> e1.delete() 181 f 172 182 173 183 >>> e2 = E() 174 184 >>> e2.save() … … 185 195 [<class 'modeltests.delete.models.F'>, <class 'modeltests.delete.models.E'>] 186 196 187 197 >>> f2.delete() 198 f 188 199 200 # Put this back to normal 201 >>> UpdateQuery.clear_related = old_clear_related 189 202 """ 190 203 }