#35167: JSONFIeld get_db_prep_value being called with `Cast` types ---------------------------------+------------------------------------ Reporter: Samantha Hughes | Owner: (none) Type: Bug | Status: new Component: Error reporting | Version: 4.2 Severity: Normal | Resolution: Keywords: JSONField | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ---------------------------------+------------------------------------ Changes (by Simon Charette):
* type: Uncategorized => Bug * stage: Unreviewed => Accepted Comment: This highly likely relates to #34539 which was about making sure `get_db_prep_value` **always** calls `get_prep_value` as it use to be case in 4.1. Given the default implementation of `get_db_prep_save` doesn't delegate to `get_db_prep_value` [https://github.com/django/django/blob/9cefdfc43f0bae696b56fa5a0bf22346f85affff/django/db/models/fields/__init__.py#L1012-L1013 when provided a compilable expression] I believe we should also make sure `JSONField.get_db_prep_save` does something equivalent. The challenge here is that `Value(output_field=JSONField())`, which represents wrapped literal JSON values which could also be JSON strings, must be able to make their way to `connection.ops.adapt_json_value(value, self.encoder)`. At least they needed during the deprecation period maybe it's no longer the case since `Value(value).as_sql` will do the right thing by itself. -- Ticket URL: <https://code.djangoproject.com/ticket/35167#comment:1> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018d7c718193-e0246539-c3aa-486e-bb88-1038c4e239ce-000000%40eu-central-1.amazonses.com.