Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #17429 -- Ensured that `Meta.ordering=None` works the same if i…

…t were an empty list. Thanks to self[at]dicos[dot]ru for the report and to bigkevmcd for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17334 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c93933441e77cefbcb354196bda9a29b7e75df18 1 parent 31b1cbc
Julien Phalip authored
4  django/db/models/sql/compiler.py
@@ -347,7 +347,9 @@ def get_ordering(self):
347 347
         elif not self.query.default_ordering:
348 348
             ordering = self.query.order_by
349 349
         else:
350  
-            ordering = self.query.order_by or self.query.model._meta.ordering
  350
+            ordering = (self.query.order_by
  351
+                        or self.query.model._meta.ordering
  352
+                        or [])
351 353
         qn = self.quote_name_unless_alias
352 354
         qn2 = self.connection.ops.quote_name
353 355
         distinct = self.query.distinct
11  tests/regressiontests/queries/tests.py
@@ -830,6 +830,17 @@ def test_ticket8439(self):
830 830
             1
831 831
         )
832 832
 
  833
+    def test_ticket17429(self):
  834
+        """
  835
+        Ensure that Meta.ordering=None works the same as Meta.ordering=[]
  836
+        """
  837
+        original_ordering = Tag._meta.ordering
  838
+        Tag._meta.ordering = None
  839
+        self.assertQuerysetEqual(
  840
+            Tag.objects.all(),
  841
+            ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'],
  842
+        )
  843
+        Tag._meta.ordering = original_ordering
833 844
 
834 845
 class Queries2Tests(TestCase):
835 846
     def setUp(self):

0 notes on commit c939334

Please sign in to comment.
Something went wrong with that request. Please try again.