diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-09-14 16:03:52 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-09-18 22:12:40 +0200 |
| commit | 5e4c1793b714a975400b9277a66f99efafa2d92c (patch) | |
| tree | d2d0e165f563a1f25534751245c6e921442d7a1e /django/contrib/postgres | |
| parent | 69af3bea9987044c944b5bc83e32c35f0a73c6dd (diff) | |
Refs #33308 -- Removed support for passing encoded JSON string literals to JSONField & co.
Per deprecation timeline.
Diffstat (limited to 'django/contrib/postgres')
| -rw-r--r-- | django/contrib/postgres/aggregates/general.py | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/django/contrib/postgres/aggregates/general.py b/django/contrib/postgres/aggregates/general.py index c8eea1034d..5de53676f6 100644 --- a/django/contrib/postgres/aggregates/general.py +++ b/django/contrib/postgres/aggregates/general.py @@ -1,9 +1,5 @@ -import json -import warnings - from django.contrib.postgres.fields import ArrayField from django.db.models import Aggregate, BooleanField, JSONField, TextField, Value -from django.utils.deprecation import RemovedInDjango51Warning from .mixins import OrderableAggMixin @@ -57,35 +53,6 @@ class JSONBAgg(OrderableAggMixin, Aggregate): allow_distinct = True output_field = JSONField() - # RemovedInDjango51Warning: When the deprecation ends, remove __init__(). - def __init__(self, *expressions, default=None, **extra): - super().__init__(*expressions, default=default, **extra) - if ( - isinstance(default, Value) - and isinstance(default.value, str) - and not isinstance(default.output_field, JSONField) - ): - value = default.value - try: - decoded = json.loads(value) - except json.JSONDecodeError: - warnings.warn( - "Passing a Value() with an output_field that isn't a JSONField as " - "JSONBAgg(default) is deprecated. Pass default=" - f"Value({value!r}, output_field=JSONField()) instead.", - stacklevel=2, - category=RemovedInDjango51Warning, - ) - self.default.output_field = self.output_field - else: - self.default = Value(decoded, self.output_field) - warnings.warn( - "Passing an encoded JSON string as JSONBAgg(default) is " - f"deprecated. Pass default={decoded!r} instead.", - stacklevel=2, - category=RemovedInDjango51Warning, - ) - class StringAgg(OrderableAggMixin, Aggregate): function = "STRING_AGG" |
