mirror of https://github.com/django/django.git
Refs #12990 -- Removed django.contrib.postgres.fields.jsonb.KeyTransform/KeyTextTransform.
Per deprecation timeline.
This commit is contained in:
parent
7cb5712edc
commit
8fdb5a656a
|
@ -1,11 +1,4 @@
|
|||
import warnings
|
||||
|
||||
from django.db.models import JSONField as BuiltinJSONField
|
||||
from django.db.models.fields.json import (
|
||||
KeyTextTransform as BuiltinKeyTextTransform,
|
||||
KeyTransform as BuiltinKeyTransform,
|
||||
)
|
||||
from django.utils.deprecation import RemovedInDjango40Warning
|
||||
|
||||
__all__ = ['JSONField']
|
||||
|
||||
|
@ -19,24 +12,3 @@ class JSONField(BuiltinJSONField):
|
|||
'hint': 'Use django.db.models.JSONField instead.',
|
||||
'id': 'fields.E904',
|
||||
}
|
||||
|
||||
|
||||
class KeyTransform(BuiltinKeyTransform):
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn(
|
||||
'django.contrib.postgres.fields.jsonb.KeyTransform is deprecated '
|
||||
'in favor of django.db.models.fields.json.KeyTransform.',
|
||||
RemovedInDjango40Warning, stacklevel=2,
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class KeyTextTransform(BuiltinKeyTextTransform):
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn(
|
||||
'django.contrib.postgres.fields.jsonb.KeyTextTransform is '
|
||||
'deprecated in favor of '
|
||||
'django.db.models.fields.json.KeyTextTransform.',
|
||||
RemovedInDjango40Warning, stacklevel=2,
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -316,3 +316,6 @@ to remove usage of these features.
|
|||
|
||||
* The ``django.contrib.postgres.fields.JSONField`` model field is removed,
|
||||
except for support in historical migrations.
|
||||
|
||||
* ``django.contrib.postgres.fields.jsonb.KeyTransform`` and
|
||||
``django.contrib.postgres.fields.jsonb.KeyTextTransform`` are removed.
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
try:
|
||||
from django.contrib.postgres import forms
|
||||
from django.contrib.postgres.fields.jsonb import (
|
||||
KeyTextTransform, KeyTransform,
|
||||
)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
@ -19,20 +16,3 @@ class DeprecationTests(PostgreSQLSimpleTestCase):
|
|||
)
|
||||
with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
|
||||
forms.JSONField()
|
||||
|
||||
def test_key_transform_deprecation_message(self):
|
||||
msg = (
|
||||
'django.contrib.postgres.fields.jsonb.KeyTransform is deprecated '
|
||||
'in favor of django.db.models.fields.json.KeyTransform.'
|
||||
)
|
||||
with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
|
||||
KeyTransform('foo', 'bar')
|
||||
|
||||
def test_key_text_transform_deprecation_message(self):
|
||||
msg = (
|
||||
'django.contrib.postgres.fields.jsonb.KeyTextTransform is '
|
||||
'deprecated in favor of '
|
||||
'django.db.models.fields.json.KeyTextTransform.'
|
||||
)
|
||||
with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
|
||||
KeyTextTransform('foo', 'bar')
|
||||
|
|
Loading…
Reference in New Issue