Changeset 6521
- Timestamp:
- 10/15/07 00:51:19 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/django/db/models/query.py
r6517 r6521 295 295 obj = self._clone() 296 296 obj.query.select_related = true_or_false 297 obj.query.max_depth = depth 297 if depth: 298 obj.query.max_depth = depth 298 299 return obj 299 300 django/branches/queryset-refactor/django/db/models/sql/query.py
r6517 r6521 88 88 self.distinct = False 89 89 self.select_related = False 90 self.max_depth = 0 90 91 # Arbitrary maximum limit for select_related to prevent infinite 92 # recursion. Can be changed by the depth parameter to select_related(). 93 self.max_depth = 5 91 94 92 95 # These are for extensions. The contents are more or less appended django/branches/queryset-refactor/tests/regressiontests/queries/models.py
r6519 r6521 80 80 def __unicode__(self): 81 81 return self.title 82 83 # Some funky cross-linked models for testing a couple of infinite recursion 84 # cases. 85 class X(models.Model): 86 y = models.ForeignKey('Y') 87 88 class Y(models.Model): 89 x1 = models.ForeignKey(X, related_name='y1') 82 90 83 91 __test__ = {'API_TESTS':""" … … 354 362 [{'note': 1}, {'note': 2}] 355 363 356 # Bug5261364 Bug #5261 357 365 >>> Note.objects.exclude(Q()) 358 366 [<Note: n1>, <Note: n2>, <Note: n3>] 359 367 368 Bug #3045, #3288 369 Once upon a time, select_related() with circular relations would loop 370 infinitely if you forgot to specify "depth". Now we set an arbitrary default 371 upper bound. 372 >>> X.objects.all() 373 [] 374 >>> X.objects.select_related() 375 [] 376 360 377 """} 361 378
