diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 4d0d295..8472de2 100644
|
a
|
b
|
def fill_table_cache(opts, select, tables, where, old_prefix, cache_tables_seen,
|
| 852 | 852 | """ |
| 853 | 853 | |
| 854 | 854 | # 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: |
| 856 | 856 | return None |
| 857 | 857 | |
| 858 | 858 | qn = connection.ops.quote_name |
diff --git a/tests/modeltests/select_related/models.py b/tests/modeltests/select_related/models.py
index 43efab3..60e66b5 100644
|
a
|
b
|
__test__ = {'API_TESTS':"""
|
| 147 | 147 | >>> len(db.connection.queries) |
| 148 | 148 | 5 |
| 149 | 149 | |
| | 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 |
| | 155 | True |
| | 156 | |
| 150 | 157 | # Reset DEBUG to where we found it. |
| 151 | 158 | >>> settings.DEBUG = False |
| 152 | 159 | """} |