Changes between Initial Version and Version 1 of Ticket #13839, comment 18


Ignore:
Timestamp:
Jan 8, 2012, 10:19:13 AM (13 years ago)
Author:
Łukasz Rekucki

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #13839, comment 18

    initial v1  
    33> 1. The point of selected_related() is that it avoids doing an extra lookup. With the proposed fix, when the related object does not exist, accessing the attribute will cause the lookup to happen. This throws the `DoesNotExist` as it ought to, but the lookup shouldn't happen at all. I imagine that one way to fix this, while preserving the efficiency of select_related, is to use some other sentinel value that triggers a `DoesNotExist` exception inside the OneToOne descriptor. (Since querysets need to be pickled, remember that the simplest choice of sentinel value is a class).
    44
    5 Added test for this. A second sentinel is not needed, because we can just check the field.null if None is a valid value.
     5Added test for this. A second sentinel is not needed, because we can just check the field.null if None is a valid value (Edit: currently, this is always False so we can just raise the exception on None, see below).
    66
    77>
Back to Top