mirror of
https://github.com/django/django.git
synced 2025-08-31 07:47:37 +00:00
Fixed #29166 -- Fixed crash in When() expression with a list argument.
Thanks Matthew Pava for the report and Tim Graham and Carlton Gibson for
reviews.
Regression in 19b2dfd1bf
.
This commit is contained in:
parent
3fb718f17d
commit
54f80430be
3 changed files with 27 additions and 1 deletions
|
@ -1288,6 +1288,24 @@ class CaseDocumentationExamples(TestCase):
|
|||
transform=attrgetter('name', 'account_type')
|
||||
)
|
||||
|
||||
def test_hash(self):
|
||||
expression_1 = Case(
|
||||
When(account_type__in=[Client.REGULAR, Client.GOLD], then=1),
|
||||
default=2,
|
||||
output_field=models.IntegerField(),
|
||||
)
|
||||
expression_2 = Case(
|
||||
When(account_type__in=(Client.REGULAR, Client.GOLD), then=1),
|
||||
default=2,
|
||||
output_field=models.IntegerField(),
|
||||
)
|
||||
expression_3 = Case(When(account_type__in=[Client.REGULAR, Client.GOLD], then=1), default=2)
|
||||
expression_4 = Case(When(account_type__in=[Client.PLATINUM, Client.GOLD], then=2), default=1)
|
||||
self.assertEqual(hash(expression_1), hash(expression_2))
|
||||
self.assertNotEqual(hash(expression_2), hash(expression_3))
|
||||
self.assertNotEqual(hash(expression_1), hash(expression_4))
|
||||
self.assertNotEqual(hash(expression_3), hash(expression_4))
|
||||
|
||||
|
||||
class CaseWhenTests(SimpleTestCase):
|
||||
def test_only_when_arguments(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue