#14615: Related objects manager returns related objects with null FKs for 
unsaved
instances
--------------------------------------+-------------------------------------
          Reporter:  tonnzor          |         Owner:     
            Status:  reopened         |     Milestone:  1.3
         Component:  ORM aggregation  |       Version:  1.2
        Resolution:                   |      Keywords:     
             Stage:  Accepted         |     Has_patch:  0  
        Needs_docs:  0                |   Needs_tests:  0  
Needs_better_patch:  0                |  
--------------------------------------+-------------------------------------
Comment (by tonnzor):

 My idea was to fix this in a very straight way - change ForeignKey
 behavior (the piece of code that generates many_set method) - so it
 doesn't take into account null.

 Let me explain a bit more. If foreign key is null - then there's no link
 between objects. So *_set should return EMPTY set disregarding DB state.

 Using object state (saved/not saved) makes this thing much more
 complicated and have unpredicted not covered cases. If user changed object
 PK and didn't save that into DB - that's his decision, we should not keep
 the state.

 Another edge case is null PK (user used custom field as PK) - that is
 simply covered by initial code, but not by object state.

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

Reply via email to