1
0
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 in c8b6594305.

Thanks Kevin Marsh for the report.

Backport of 96f55ccf79 from main
This commit is contained in:
Simon Charette
2021-05-04 17:49:46 -04:00
committed by Mariusz Felisiak
parent df801dde33
commit 364098fdac
3 changed files with 26 additions and 3 deletions

View File

@@ -1947,3 +1947,25 @@ class ExpressionWrapperTests(SimpleTestCase):
group_by_cols = expr.get_group_by_cols(alias=None)
self.assertEqual(group_by_cols, [expr.expression])
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)),
)