Opened 10 years ago

Closed 10 years ago

#8223 closed (invalid)

Infinite loop caused by ordering

Reported by: David Cramer Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The model itself contains no data in the database:

class Syntax(models.Model):
    name    = models.CharField(max_length=32)
    lexer   = models.CharField(max_length=32)
    order   = models.IntegerField(default=10)
    parent  = models.ForeignKey('self', blank=True, null=True)
    children= models.SmallIntegerField(default=0)

    class Meta:
        ordering = ('parent', 'order', 'name')

File "/Library/Python/2.5/site-packages/django/core/handlers/" in get_response
  77.                     request.path_info)
File "/Library/Python/2.5/site-packages/django/core/" in resolve
  240.                     sub_match = pattern.resolve(new_path)
File "/Library/Python/2.5/site-packages/django/core/" in resolve
  240.                     sub_match = pattern.resolve(new_path)
File "/Library/Python/2.5/site-packages/django/core/" in resolve
  179.             return self.callback, args, kwargs
File "/Library/Python/2.5/site-packages/django/core/" in _get_callback
  185.             self._callback = get_callable(self._callback_str)
File "/Users/dcramer/Development/django-compositepks/django/utils/" in wrapper
  130.         result = func(*args)
File "/Library/Python/2.5/site-packages/django/core/" in get_callable
  54.                 lookup_view = getattr(__import__(mod_name, {}, {}, ['']), func_name)
File "/Users/dcramer/Development/pastethat/pastes/" in <module>
  6. from forms import PasteFileForm, PasteLinkForm, PasteTextForm
File "/Users/dcramer/Development/pastethat/pastes/" in <module>
  55. class PasteTextForm(forms.Form):
File "/Users/dcramer/Development/pastethat/pastes/" in PasteTextForm
  56.     syntax  = GroupedModelChoiceField(queryset=Syntax.objects.all(), empty_label='(Automatic)', required=False)
File "/Library/Python/2.5/site-packages/django/forms/" in __init__
  475.         self.queryset = queryset
File "/Library/Python/2.5/site-packages/django/forms/" in _set_queryset
  483.         self.widget.choices = self.choices
File "/Users/dcramer/Development/pastethat/pastes/" in _get_choices
  41.             loop(self.queryset)
File "/Users/dcramer/Development/pastethat/pastes/" in loop
  24.                 for parent, objects in itertools.groupby(sorted(objects, key=func), key=func):
File "/Library/Python/2.5/site-packages/django/db/models/" in __len__
  153.             self._result_cache.extend(list(self._iter))
File "/Library/Python/2.5/site-packages/django/db/models/" in iterator
  266.         for row in self.query.results_iter():
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in results_iter
  200.         for rows in self.execute_sql(MULTI):
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in execute_sql
  1603.             sql, params = self.as_sql()
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in as_sql
  255.         ordering = self.get_ordering()
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in get_ordering
  613.                         self.model._meta, default_order=asc):
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in find_ordering_name
  666.                         order, already_seen))
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in find_ordering_name
  660.                 raise FieldError('Infinite loop caused by ordering.')

Change History (1)

comment:1 Changed 10 years ago by Malcolm Tredinnick

Resolution: invalid
Status: newclosed

The error isn't related to data in the database. It's an error in the model definition (the ordering by parent, which uses the default model's ordering, which includes parent, etc). Replace parent with parent__id in the ordering if you want the old (somewhat incorrect) behaviour.

Note: See TracTickets for help on using tickets.
Back to Top