#18153: Erorneous OneToOneField for instances that have pk unset
-------------------------------------+-------------------------------------
     Reporter:  jbzdak@…             |                    Owner:  dhatch
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  1.4
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:                       |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

 (1) I agree with Andrew that !SingleRelatedObjectDescriptor should return
 an error in this case, and it's what I've implemented in the patch I
 attached to #19089.

 (2) The asymmetry between forwards relations and backwards relations
 exists on purpose. The underlying relation in the database is asymmetric.
 So, at first sight, I disagree with the `and not self.related.field.null`
 part.

 I'm willing to reconsider (2), which is tracked in #10227. We can continue
 that part of the discussion over there.

 But I think we can fix (1), which is an obvious bug, without waiting for
 the decision on (2).

 Since I independently wrote the same patch as dhatch, it's probably a
 reasonable solution. I plan combine both patches — mine doesn't break on
 legit values of `pk` such as `''` or `0`, dhaty's has more tests — and
 commit the result soon.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18153#comment:11>
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