Code

Ticket #3275: test_depth_bug.diff

File test_depth_bug.diff, 622 bytes (added by marcin@…, 7 years ago)

Test case for the bug with non-zero depth

Line 
1Index: tests/modeltests/select_related/models.py
2===================================================================
3--- tests/modeltests/select_related/models.py   (revision 5122)
4+++ tests/modeltests/select_related/models.py   (working copy)
5@@ -147,6 +147,13 @@
6 >>> len(db.connection.queries)
7 5
8 
9+# Test the bug with select_related and extra combination
10+>>> s = Species.objects.all().select_related(depth=1).extra(select={'a': 'select_related_species.id + 10'})[0]
11+
12+# With the correct code the result should be True
13+>>> s.id + 10 == s.a
14+True
15+
16 # Reset DEBUG to where we found it.
17 >>> settings.DEBUG = False
18 """}