mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #33216 -- Simpilified deconstructed paths for some expressions.
This commit is contained in:
committed by
Mariusz Felisiak
parent
96e7ff5e9f
commit
28c98d4113
@@ -607,6 +607,33 @@ class WriterTests(SimpleTestCase):
|
||||
with self.assertRaisesMessage(ValueError, "Could not find object EmailValidator2 in django.core.validators."):
|
||||
MigrationWriter.serialize(validator)
|
||||
|
||||
def test_serialize_complex_func_index(self):
|
||||
index = models.Index(
|
||||
models.Func('rating', function='ABS'),
|
||||
models.Case(
|
||||
models.When(name='special', then=models.Value('X')),
|
||||
default=models.Value('other'),
|
||||
),
|
||||
models.ExpressionWrapper(
|
||||
models.F('pages'),
|
||||
output_field=models.IntegerField(),
|
||||
),
|
||||
models.OrderBy(models.F('name').desc()),
|
||||
name='complex_func_index',
|
||||
)
|
||||
string, imports = MigrationWriter.serialize(index)
|
||||
self.assertEqual(
|
||||
string,
|
||||
"models.Index(models.Func('rating', function='ABS'), "
|
||||
"models.Case(models.When(name='special', then=models.Value('X')), "
|
||||
"default=models.Value('other')), "
|
||||
"models.ExpressionWrapper("
|
||||
"models.F('pages'), output_field=models.IntegerField()), "
|
||||
"models.OrderBy(models.OrderBy(models.F('name'), descending=True)), "
|
||||
"name='complex_func_index')"
|
||||
)
|
||||
self.assertEqual(imports, {'from django.db import models'})
|
||||
|
||||
def test_serialize_empty_nonempty_tuple(self):
|
||||
"""
|
||||
Ticket #22679: makemigrations generates invalid code for (an empty
|
||||
|
||||
Reference in New Issue
Block a user