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