Ticket #9308: 9308.diff

File 9308.diff, 1.8 KB (added by Bob Thomas, 16 years ago)

Fix tests

  • django/db/models/query.py

     
    10061006            update_query = sql.UpdateQuery(cls, connection)
    10071007            for field, model in cls._meta.get_fields_with_model():
    10081008                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,
    10101010                        field.rel.to._meta.fields)):
    10111011                    if model:
    10121012                        sql.UpdateQuery(model, connection).clear_related(field,
  • tests/modeltests/delete/models.py

     
    168168>>> o.keys()
    169169[<class 'modeltests.delete.models.F'>, <class 'modeltests.delete.models.E'>]
    170170
     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)
    171180>>> e1.delete()
     181f
    172182
    173183>>> e2 = E()
    174184>>> e2.save()
     
    185195[<class 'modeltests.delete.models.F'>, <class 'modeltests.delete.models.E'>]
    186196
    187197>>> f2.delete()
     198f
    188199
     200# Put this back to normal
     201>>> UpdateQuery.clear_related = old_clear_related
    189202"""
    190203}
Back to Top