mirror of
https://github.com/django/django.git
synced 2025-08-26 13:34:25 +00:00
Fixed #29391 -- Made PostgresSimpleLookup respect Field.get_db_prep_value().
This commit is contained in:
parent
c492fdfd24
commit
5a36c81f58
5 changed files with 42 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
|||
import decimal
|
||||
import enum
|
||||
import json
|
||||
import unittest
|
||||
import uuid
|
||||
|
@ -16,9 +17,9 @@ from . import (
|
|||
PostgreSQLSimpleTestCase, PostgreSQLTestCase, PostgreSQLWidgetTestCase,
|
||||
)
|
||||
from .models import (
|
||||
ArrayFieldSubclass, CharArrayModel, DateTimeArrayModel, IntegerArrayModel,
|
||||
NestedIntegerArrayModel, NullableIntegerArrayModel, OtherTypesArrayModel,
|
||||
PostgreSQLModel, Tag,
|
||||
ArrayEnumModel, ArrayFieldSubclass, CharArrayModel, DateTimeArrayModel,
|
||||
IntegerArrayModel, NestedIntegerArrayModel, NullableIntegerArrayModel,
|
||||
OtherTypesArrayModel, PostgreSQLModel, Tag,
|
||||
)
|
||||
|
||||
try:
|
||||
|
@ -357,6 +358,16 @@ class TestQuerying(PostgreSQLTestCase):
|
|||
[self.objs[3]]
|
||||
)
|
||||
|
||||
def test_enum_lookup(self):
|
||||
class TestEnum(enum.Enum):
|
||||
VALUE_1 = 'value_1'
|
||||
|
||||
instance = ArrayEnumModel.objects.create(array_of_enums=[TestEnum.VALUE_1])
|
||||
self.assertSequenceEqual(
|
||||
ArrayEnumModel.objects.filter(array_of_enums__contains=[TestEnum.VALUE_1]),
|
||||
[instance]
|
||||
)
|
||||
|
||||
def test_unsupported_lookup(self):
|
||||
msg = "Unsupported lookup '0_bar' for ArrayField or join on the field not permitted."
|
||||
with self.assertRaisesMessage(FieldError, msg):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue