Opened 19 months ago

Last modified 18 months ago

#34539 closed Bug

`get_prep_value` no longer called for JSONField — at Initial Version

Reported by: Julie Rymer Owned by: nobody
Component: Database layer (models, ORM) Version: 4.2
Severity: Release blocker Keywords:
Cc: Simon Charette, Florian Apolloner, Tim Graham Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello, I just upgraded from django 4.1 to 4.2 and I have a custom JSONField with a get_prep_value() override that stopped working. After searching a bit, I saw that was because JSONField.get_prep_value() is no longer called in 4.2.

I think this issue need a resolution either:

  • JSONField should call get_prep_value() like all other fields type, because this is the method that the documentation tell us to override in custom fields. Otherwise we need to override get_db_prep_value() which is heavier and does not have the same purpose. I think simply replacing connection.ops.adapt_json_value(value, self.encoder) with connection.ops.adapt_json_value(self.get_prep_value(value), self.encoder) in JSONField.get_db_prep_value() would fix this

PS: #34397 seems to be related but in fact is about Django 3.2 so it is not the current issue

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top