#11811: No error raised on update(foreignkey=unsavedobject) on nullable fk
---------------------------------------------------+------------------------
          Reporter:  Afief                         |         Owner:  ashearer
            Status:  assigned                      |     Milestone:  1.2     
         Component:  Database layer (models, ORM)  |       Version:  1.1     
        Resolution:                                |      Keywords:          
             Stage:  Accepted                      |     Has_patch:  1       
        Needs_docs:  0                             |   Needs_tests:  0       
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by ashearer):

  * has_patch:  0 => 1

Comment:

 The updated patch (rev-5) doesn't raise exceptions for model instances
 that are never saved anyway, which fixes the multi-DB test failures.

 The one remaining design issue is a backward compatibility vs. consistency
 tradeoff. The patch errs on the side of backward compatibility: if the
 foreign key field is declared non-null, assignment works as before, and
 lets the database raise its own integrity error instead of the new
 ValueError exception with a detailed error message. The queryset.update()
 patch can't tell how the field is declared, though, so it always raises
 ValueError. Raising ValueError in all cases would be more consistent and
 probably more helpful, but it could break compatibility for code that's
 already expecting to catch a particular integrity error.

 Also, the patch could attempt to be smart. When it detects that the
 foreign key value is missing but there is a cached instance, it could fill
 the key in from that instance, in case the instance was saved after the
 assignment. But that's starting to get magical, so it doesn't do that.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11811#comment:5>
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to