mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[3.2.x] Fixed #32714 -- Prevented recreation of migration for Meta.ordering with OrderBy expressions.
Regression inc8b6594305. Thanks Kevin Marsh for the report. Backport of96f55ccf79from main
This commit is contained in:
committed by
Mariusz Felisiak
parent
df801dde33
commit
364098fdac
@@ -1174,8 +1174,7 @@ class Exists(Subquery):
|
|||||||
return sql, params
|
return sql, params
|
||||||
|
|
||||||
|
|
||||||
@deconstructible
|
class OrderBy(Expression):
|
||||||
class OrderBy(BaseExpression):
|
|
||||||
template = '%(expression)s %(ordering)s'
|
template = '%(expression)s %(ordering)s'
|
||||||
conditional = False
|
conditional = False
|
||||||
|
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ Django 3.2.2 fixes several bugs in 3.2.1.
|
|||||||
Bugfixes
|
Bugfixes
|
||||||
========
|
========
|
||||||
|
|
||||||
* ...
|
* Prevented, following a regression in Django 3.2.1, :djadmin:`makemigrations`
|
||||||
|
from generating infinite migrations for a model with ``Meta.ordering``
|
||||||
|
contained ``OrderBy`` expressions (:ticket:`32714`).
|
||||||
|
|||||||
@@ -1947,3 +1947,25 @@ class ExpressionWrapperTests(SimpleTestCase):
|
|||||||
group_by_cols = expr.get_group_by_cols(alias=None)
|
group_by_cols = expr.get_group_by_cols(alias=None)
|
||||||
self.assertEqual(group_by_cols, [expr.expression])
|
self.assertEqual(group_by_cols, [expr.expression])
|
||||||
self.assertEqual(group_by_cols[0].output_field, expr.output_field)
|
self.assertEqual(group_by_cols[0].output_field, expr.output_field)
|
||||||
|
|
||||||
|
|
||||||
|
class OrderByTests(SimpleTestCase):
|
||||||
|
def test_equal(self):
|
||||||
|
self.assertEqual(
|
||||||
|
OrderBy(F('field'), nulls_last=True),
|
||||||
|
OrderBy(F('field'), nulls_last=True),
|
||||||
|
)
|
||||||
|
self.assertNotEqual(
|
||||||
|
OrderBy(F('field'), nulls_last=True),
|
||||||
|
OrderBy(F('field'), nulls_last=False),
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_hash(self):
|
||||||
|
self.assertEqual(
|
||||||
|
hash(OrderBy(F('field'), nulls_last=True)),
|
||||||
|
hash(OrderBy(F('field'), nulls_last=True)),
|
||||||
|
)
|
||||||
|
self.assertNotEqual(
|
||||||
|
hash(OrderBy(F('field'), nulls_last=True)),
|
||||||
|
hash(OrderBy(F('field'), nulls_last=False)),
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user