#14368: Reverse relation attribute for OneToOneField fails when set to None ---------------------------------------------------+------------------------ Reporter: gsakkis | Owner: nobody Status: new | Milestone: 1.3 Component: Database layer (models, ORM) | Version: 1.2 Resolution: | Keywords: OneToOneField, bug Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by gruszczy):
* cc: gruszczy (added) Comment: I have created a unit test for this and a patch, but I don't know, if it is any good. I have several concerns. The test looks like this: {{{ first = First.objects.create() second = Second.objects.create() first.second = second first.second = None self.assertRaises(Second.DoesNotExist, getattr, first, 'second') self.assert_(second.first is None) }}} and I believe this is an expected behaviour. However, if we take the snippet from this ticket: {{{ In [6]: bob = Person.objects.create(age=34) In [7]: bobs_soul = Soul.objects.create(person=bob) In [8]: bob.soul == bobs_soul Out[8]: True In [9]: bob.soul = None }}} then setting bob.soul to None doesn't have any effect, because bob.soul is created by a Query, so without changing data in the database you can't really affect it. I will post my patch and if someone could point me, how it should work, I will be glad to change it the way it should work. -- Ticket URL: <http://code.djangoproject.com/ticket/14368#comment:8> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.