#3288: ForeignKey to 'self' and select_related() = infinite recursion
---------------------------------------------+------------------------------
 Reporter:  Max Derkachev <[EMAIL PROTECTED]>  |       Owner:  adrian
     Type:  defect                           |      Status:  new   
 Priority:  normal                           |   Milestone:        
Component:  Database wrapper                 |     Version:        
 Severity:  major                            |    Keywords:        
---------------------------------------------+------------------------------
 Maybe it's a variant of #3045 bug.
 The [simplified] case is
 {{{
 #!python
 class Foo(models.Model):
     parent = models.ForeignKey('self')
 
     class Meta:
        db_table = 'foos'
 
 foo = Foo.objects.select_related().get(pk=1)
 }}}
 
 That leads to infinite recursion in
 django.db.models.query.fill_table_cache. The bottom of the stack trace is:
 {{{
   ........ many many lines ............
   File "/home/maxim/dproject/django/db/models/query.py", line 684, in
 fill_table_cache
     fill_table_cache(f.rel.to._meta, select, tables, where, db_table,
 cache_tables_seen)
   File "/home/maxim/dproject/django/db/models/query.py", line 684, in
 fill_table_cache
     fill_table_cache(f.rel.to._meta, select, tables, where, db_table,
 cache_tables_seen)
   File "/home/maxim/dproject/django/db/models/query.py", line 681, in
 fill_table_cache
     where.append('%s.%s = %s.%s' % \
   File "/home/maxim/dproject/django/db/models/fields/related.py", line
 737, in get_related_field
     return self.to._meta.get_field(self.field_name)
   File "/home/maxim/dproject/django/db/models/options.py", line 98, in
 get_field
     if f.name == name:
 RuntimeError: maximum recursion depth exceeded in cmp
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3288>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to