mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #23758 -- Allowed more than 5 levels of subqueries
Refactored bump_prefix() to avoid infinite loop and allow more than than 5 subquires by extending the alphabet to use multi-letters.
This commit is contained in:
committed by
Tim Graham
parent
478d6a9503
commit
41fc1c0b5e
@@ -383,6 +383,25 @@ class Queries1Tests(BaseQuerysetTest):
|
||||
['<Item: four>']
|
||||
)
|
||||
|
||||
def test_avoid_infinite_loop_on_too_many_subqueries(self):
|
||||
x = Tag.objects.filter(pk=1)
|
||||
local_recursion_limit = 127
|
||||
msg = 'Maximum recursion depth exceeded: too many subqueries.'
|
||||
with self.assertRaisesMessage(RuntimeError, msg):
|
||||
for i in six.moves.range(local_recursion_limit * 2):
|
||||
x = Tag.objects.filter(pk__in=x)
|
||||
|
||||
def test_reasonable_number_of_subq_aliases(self):
|
||||
x = Tag.objects.filter(pk=1)
|
||||
for _ in xrange(20):
|
||||
x = Tag.objects.filter(pk__in=x)
|
||||
self.assertEqual(
|
||||
x.query.subq_aliases, {
|
||||
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD',
|
||||
'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN',
|
||||
}
|
||||
)
|
||||
|
||||
def test_heterogeneous_qs_combination(self):
|
||||
# Combining querysets built on different models should behave in a well-defined
|
||||
# fashion. We raise an error.
|
||||
|
||||
Reference in New Issue
Block a user