summaryrefslogtreecommitdiff
path: root/django/db/models/sql/compiler.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2022-11-02 22:03:05 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-12-01 19:14:00 +0100
commit0ff46591ac3010841c73fd26e0fef93995fedd99 (patch)
tree7373b7f028df958db09d353e603124bc52b37bed /django/db/models/sql/compiler.py
parentd3e746ace5eeea07216da97d9c3801f2fdc43223 (diff)
downloaddjango-0ff46591ac3010841c73fd26e0fef93995fedd99.tar.gz
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 'django/db/models/sql/compiler.py')
-rw-r--r--django/db/models/sql/compiler.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index caf36382b5..2b66ab12b4 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1637,9 +1637,7 @@ class SQLInsertCompiler(SQLCompiler):
"Window expressions are not allowed in this query (%s=%r)."
% (field.name, value)
)
- else:
- value = field.get_db_prep_save(value, connection=self.connection)
- return value
+ return field.get_db_prep_save(value, connection=self.connection)
def pre_save_val(self, field, obj):
"""
@@ -1893,18 +1891,14 @@ class SQLUpdateCompiler(SQLCompiler):
)
elif hasattr(val, "prepare_database_save"):
if field.remote_field:
- val = field.get_db_prep_save(
- val.prepare_database_save(field),
- connection=self.connection,
- )
+ val = val.prepare_database_save(field)
else:
raise TypeError(
"Tried to update field %s with a model instance, %r. "
"Use a value compatible with %s."
% (field, val, field.__class__.__name__)
)
- else:
- val = field.get_db_prep_save(val, connection=self.connection)
+ val = field.get_db_prep_save(val, connection=self.connection)
# Getting the placeholder for the field.
if hasattr(field, "get_placeholder"):