Ticket #17429: bug_17429.patch

File bug_17429.patch, 1.3 KB (added by bigkevmcd, 13 years ago)

Simple test and patch for this (it was throwing an error because None is not iterable)

  • django/db/models/sql/compiler.py

     
    309309        elif not self.query.default_ordering:
    310310            ordering = self.query.order_by
    311311        else:
    312             ordering = self.query.order_by or self.query.model._meta.ordering
     312            ordering = self.query.order_by or self.query.model._meta.ordering or ()
    313313        qn = self.quote_name_unless_alias
    314314        qn2 = self.connection.ops.quote_name
    315315        distinct = self.query.distinct
  • tests/regressiontests/queries/tests.py

     
    826826            1
    827827        )
    828828
     829    def test_ticket17429(self):
     830        original_ordering = Tag._meta.ordering
     831        try:
     832            Tag._meta.ordering = None
     833            self.assertQuerysetEqual(
     834                Tag.objects.all(),
     835                ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'],
     836            )
     837        finally:
     838            Tag._meta.ordering = original_ordering
    829839
    830840class Queries2Tests(TestCase):
    831841    def setUp(self):
Back to Top