Django

Code

Changeset 6755

Show
Ignore:
Timestamp:
11/29/07 16:07:58 (7 months ago)
Author:
mtredinnick
Message:

queryset-refactor: Fixed an off-by-one error when filling the select-related
case. Only affects people using select_related() with the "depth" parameter
*and* extra(select=...) simultaneously. Refs #6018. Thanks, Matthias Urlichs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/django/db/models/sql/query.py

    r6730 r6755  
    635635        return alias 
    636636 
    637     def fill_related_selections(self, opts=None, root_alias=None, cur_depth=0
     637    def fill_related_selections(self, opts=None, root_alias=None, cur_depth=1
    638638            used=None): 
    639639        """ 
    640         Fill in the information needed for a select_related query. 
     640        Fill in the information needed for a select_related query. The current 
     641        "depth" is measured as the number of connections away from the root 
     642        model (cur_depth == 1 means we are looking at models with direct 
     643        connections to the root model). 
    641644        """ 
    642645        if self.max_depth and cur_depth > self.max_depth: 
  • django/branches/queryset-refactor/tests/modeltests/select_related/models.py

    r6522 r6755  
    1481485 
    149149 
     150>>> s = Species.objects.all().select_related(depth=1).extra(select={'a': 'select_related_species.id + 10'})[0] 
     151>>> s.id + 10 == s.a 
     152True 
     153 
    150154# Reset DEBUG to where we found it. 
    151155>>> settings.DEBUG = False