#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 dhatch):

 Replying to [comment:5 akaariai]:
 > I vote for consistency with foreign key fields. It seems the right
 behavior to me. Although I have no idea how bad the breakage will be.
 There is always the possibility to claim this to be a bugfix and thus
 backwards compatibility does not apply... :)
 >
 > As for the patch, it seems good to me. The question is if that is really
 the behavior we want to commit into.
 Agreed.  Will modify the patch to be consistent with foreign keys, seems
 right to me as well.

 The behavior before was as follows:

 1) If no objects of the reverse one to one type existed in the database
 DoesNotExist was raised (regardless of null).

 2) If one object of the reverse one to one type existed in the database,
 it was returned, regardless of the fact that the field was not set.
 (Clearly this scenario is a bug)

 3) If multiple objects of the reverse type exist, MultipleObjectsReturned
 is raised.

 After the patch the behavior for all these three cases will either be to
 raise DoesNotExist or return null if the field is nullable when the pk of
 the model is not set.

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