#35167: JSONFIeld get_db_prep_value being called with `Cast` types
-------------------------------------------+---------------------------
Reporter: shughes-uk | Owner: (none)
Type: Uncategorized | Status: new
Component: Error reporting | Version: 4.2
Severity: Normal | Keywords: JSONField
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+---------------------------
Running django 4.2.9.
We have a customized version of the standard `JsonField` where we have
overridden `from_db_value` and `get_prep_value`.
The worked in django ~4.1. Migrating to 4.2.9, the `get_prep_value`
function started receiving `Cast` objects as the `value`, exploding json
serializing/encryption , only during `bulk_update`.
We fixed it by overriding `get_db_prep_save to
{{{
def get_db_prep_save(self, value, connection):
if hasattr(value, "as_sql"):
return value
return self.get_db_prep_value(value, connection=connection,
prepared=False)
}}}
The jsonfield implementation does not check for `as_sql`. I'm not sure if
this is intentional or not (unmodified JSONField columns don't seem to
explode), possibly our implementation has messed up the jsonfield?
--
Ticket URL: <https://code.djangoproject.com/ticket/35167>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018d7c18377a-13ce5ff9-c6ba-4b21-9781-467aa45d8e53-000000%40eu-central-1.amazonses.com.