﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23758	Going beyond 5 levels of subqueries causes AssertionError in bump_prefix	Richard Howard	Piotr Pawlaczek	"Regression from Django 1.6

The following code in the interactive shell will reproduce the issue:

{{{#!python
from django.contrib.auth.models import User
i = 0
x = User.objects.filter(pk=1)
while True:
    x = User.objects.filter(pk__in=x)
    i+=1
}}}
In django 1.7 it will throw the following AssertionError

{{{#!python
...
... in bump_prefix(self, outer_query)
    829         while self.alias_prefix in self.subq_aliases:
    830             self.alias_prefix = chr(ord(self.alias_prefix) + 1)
--> 831             assert self.alias_prefix < 'Z'
    832         self.subq_aliases = self.subq_aliases.union([self.alias_prefix])
    833         outer_query.subq_aliases = outer_query.subq_aliases.union(self.subq_aliases)

AssertionError: 
}}}

while in django 1.6 it will loop infinitely.

I have tested this using multiple models in the loop, with the same outcome.
"	Bug	closed	Database layer (models, ORM)	1.7	Normal	fixed	bump_prefix subquery alias		Ready for checkin	1	0	0	0	0	0
