diff options
| author | Simon Charette <charette.s@gmail.com> | 2022-11-02 22:03:05 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-12-01 19:14:00 +0100 |
| commit | 0ff46591ac3010841c73fd26e0fef93995fedd99 (patch) | |
| tree | 7373b7f028df958db09d353e603124bc52b37bed /docs/releases | |
| parent | d3e746ace5eeea07216da97d9c3801f2fdc43223 (diff) | |
Refs #33308 -- Deprecated support for passing encoded JSON string literals to JSONField & co.
JSON should be provided as literal Python objects an not in their
encoded string literal forms.
Diffstat (limited to 'docs/releases')
| -rw-r--r-- | docs/releases/4.2.txt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 8153eefebc..054f8d6621 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -444,6 +444,42 @@ but it should not be used for new migrations. Use :class:`~django.db.migrations.operations.AddIndex` and :class:`~django.db.migrations.operations.RemoveIndex` operations instead. +Passing encoded JSON string literals to ``JSONField`` is deprecated +------------------------------------------------------------------- + +``JSONField`` and its associated lookups and aggregates use to allow passing +JSON encoded string literals which caused ambiguity on whether string literals +were already encoded from database backend's perspective. + +During the deprecation period string literals will be attempted to be JSON +decoded and a warning will be emitted on success that points at passing +non-encoded forms instead. + +Code that use to pass JSON encoded string literals:: + + Document.objects.bulk_create( + Document(data=Value("null")), + Document(data=Value("[]")), + Document(data=Value('"foo-bar"')), + ) + Document.objects.annotate( + JSONBAgg("field", default=Value('[]')), + ) + +Should become:: + + Document.objects.bulk_create( + Document(data=Value(None, JSONField())), + Document(data=[]), + Document(data="foo-bar"), + ) + Document.objects.annotate( + JSONBAgg("field", default=[]), + ) + +From Django 5.1+ string literals will be implicitly interpreted as JSON string +literals. + Miscellaneous ------------- |
