Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 jphalip authored
4 django/db/models/sql/compiler.py
View
@@ -347,7 +347,9 @@ def get_ordering(self):
elif not self.query.default_ordering:
ordering = self.query.order_by
else:
- ordering = self.query.order_by or self.query.model._meta.ordering
+ ordering = (self.query.order_by
+ or self.query.model._meta.ordering
+ or [])
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
distinct = self.query.distinct
11 tests/regressiontests/queries/tests.py
View
@@ -830,6 +830,17 @@ def test_ticket8439(self):
1
)
+ def test_ticket17429(self):
+ """
+ Ensure that Meta.ordering=None works the same as Meta.ordering=[]
+ """
+ original_ordering = Tag._meta.ordering
+ Tag._meta.ordering = None
+ self.assertQuerysetEqual(
+ Tag.objects.all(),
+ ['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>'],
+ )
+ Tag._meta.ordering = original_ordering
class Queries2Tests(TestCase):
def setUp(self):
Please sign in to comment.
Something went wrong with that request. Please try again.