#18638: Reverse OneToOne relationship does not save properly.
----------------------------------------------+--------------------
     Reporter:  dhatch                        |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.4
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  1
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 When the reverse side of a one-to-one relationship is assigned to and the
 model is saved, the association is not properly written to the database.

 Example:

 Models:
 {{{
 class Tag(models.Model):
     data = models.OneToOneField("Data")

 class Data(models.Model):
     pass
 }}}

 Run:
 {{{
 data = Data()
 t = Tag.objects.create()
 data.tag = t
 data.save()
 # refresh from db
 data = Data.objects.get(pk=data.pk)
 data.tag # raises DoesNotExist
 }}}

 Attached is a patch including a test case which illustrates this issue.
 To run the test case cd to the tests directory then...

 {{{export PYTHONPATH=`pwd`:`pwd`/..; ./runtests.py --settings=test_sqlite
 one_to_one_regress}}}

 '''test_reverse_one_to_one_save''' should fail.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18638>
Django <https://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-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to