#24654: infinite loop caused by ordering, triggered by relational primary key construct ----------------------------------------------+-------------------- Reporter: elmbeech | Owner: nobody Type: Bug | Status: new Component: Database layer (models, ORM) | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------------------+-------------------- = Source Code = == models.py file ==
{{{#!python from django.db import models class Organism( models.Model ): organism = models.SlugField( primary_key=True ) class Meta: ordering = ["organism"] class TheLoop( models.Model ): loop = models.SlugField( primary_key=True ) target_organism = models.ForeignKey( Organism ) host_organism = models.ForeignKey( Organism ) class Meta: ordering = ["target_organism","host_organism"] #"loop" class InfinitLoop( models.Model): infinity = models.SlugField( primary_key=True ) loop = models.ForeignKey( TheLoop ) class Meta: ordering = ["loop"] #"infinity" }}} == test.py file == {{{#!python from django.test import TestCase from .models import InfinitLoop , TheLoop class InfinitLoopTests( TestCase ): def test_infinitloop( self ): #print( TheLoop.objects.all() ) print( InfinitLoop.objects.all() ) }}} = Trace Back = {{{ (djangovenv) JOSHUA ~/src/django/tests $ PYTHONPATH=..:$PYTHONPATH python runtests.py infinitloop Testing against Django installed in '/Users/buchere/src/django/django' Creating test database for alias 'default'... Creating test database for alias 'other'... E ====================================================================== ERROR: test_infinitloop (infinitloop.test.InfinitLoopTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/buchere/src/django/tests/infinitloop/test.py", line 8, in test_infinitloop print( InfinitLoop.objects.all() ) File "/Users/buchere/src/django/django/db/models/query.py", line 234, in __repr__ data = list(self[:REPR_OUTPUT_SIZE + 1]) File "/Users/buchere/src/django/django/db/models/query.py", line 258, in __iter__ self._fetch_all() File "/Users/buchere/src/django/django/db/models/query.py", line 1061, in _fetch_all self._result_cache = list(self.iterator()) File "/Users/buchere/src/django/django/db/models/query.py", line 52, in __iter__ results = compiler.execute_sql() File "/Users/buchere/src/django/django/db/models/sql/compiler.py", line 824, in execute_sql sql, params = self.as_sql() File "/Users/buchere/src/django/django/db/models/sql/compiler.py", line 373, in as_sql extra_select, order_by, group_by = self.pre_sql_setup() File "/Users/buchere/src/django/django/db/models/sql/compiler.py", line 49, in pre_sql_setup order_by = self.get_order_by() File "/Users/buchere/src/django/django/db/models/sql/compiler.py", line 285, in get_order_by field, self.query.get_meta(), default_order=asc)) File "/Users/buchere/src/django/django/db/models/sql/compiler.py", line 570, in find_ordering_name order, already_seen)) File "/Users/buchere/src/django/django/db/models/sql/compiler.py", line 564, in find_ordering_name raise FieldError('Infinite loop caused by ordering.') django.core.exceptions.FieldError: Infinite loop caused by ordering. ---------------------------------------------------------------------- Ran 1 test in 0.002s FAILED (errors=1) Destroying test database for alias 'default'... Destroying test database for alias 'other'... (djangovenv) JOSHUA ~/src/django/tests $ }}} -- Ticket URL: <https://code.djangoproject.com/ticket/24654> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.c3e409ab3d1f7d56adaaece45205d79a%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.