Django

Code

Ticket #6018: select_related.diff

File select_related.diff, 1.2 kB (added by Matthias Urlichs <smurf@smurf.noris.de>, 7 months ago)

One-character patch plus one-line testcase

  • a/django/db/models/query.py

    old new  
    852852    """ 
    853853 
    854854    # If we've got a max_depth set and we've exceeded that depth, bail now. 
    855     if max_depth and cur_depth > max_depth: 
     855    if max_depth and cur_depth >= max_depth: 
    856856        return None 
    857857 
    858858    qn = connection.ops.quote_name 
  • a/tests/modeltests/select_related/models.py

    old new  
    147147>>> len(db.connection.queries) 
    1481485 
    149149 
     150# Test the bug with select_related and extra combination 
     151>>> s = Species.objects.all().select_related(depth=1).extra(select={'a': 'select_related_species.id + 10'})[0] 
     152 
     153# With the correct code the result should be True 
     154>>> s.id + 10 == s.a 
     155True 
     156 
    150157# Reset DEBUG to where we found it. 
    151158>>> settings.DEBUG = False 
    152159"""}