kopia lustrzana https://github.com/wagtail/wagtail
Add `StreamField.get_db_prep_value()` to delegate serialisation of `JSONField` lookup values (#9693)
Fixes #9692pull/9698/head
rodzic
682ed3b21f
commit
573107a3b6
|
@ -34,6 +34,7 @@ Changelog
|
|||
* Fix: Move DateField, DateTimeField, TimeField comment buttons to be right next to the fields (Theresa Okoro)
|
||||
* Fix: Support text resizing in workflow steps cards (Ivy Jeptoo)
|
||||
* Fix: Ignore images added via fixtures when using `WAGTAILIMAGES_FEATURE_DETECTION_ENABLED` to avoid errors for images that do not exist (Aman Pandey)
|
||||
* Fix: Restore ability to perform JSONField query operations against StreamField when running against the Django 4.2 development branch (Sage Abdullah)
|
||||
* Docs: Add custom permissions section to permissions documentation page (Dan Hayden)
|
||||
* Docs: Add documentation for how to get started with contributing translations for the Wagtail admin (Ogunbanjo Oluwadamilare)
|
||||
* Docs: Officially recommend `fnm` over `nvm` in development documentation (LB (Ben) Johnston)
|
||||
|
|
|
@ -46,6 +46,7 @@ depth: 1
|
|||
* Move DateField, DateTimeField, TimeField comment buttons to be right next to the fields (Theresa Okoro)
|
||||
* Support text resizing in workflow steps cards (Ivy Jeptoo)
|
||||
* Ignore images added via fixtures when using `WAGTAILIMAGES_FEATURE_DETECTION_ENABLED` to avoid errors for images that do not exist (Aman Pandey)
|
||||
* Restore ability to perform JSONField query operations against StreamField when running against the Django 4.2 development branch (Sage Abdullah)
|
||||
|
||||
### Documentation
|
||||
|
||||
|
|
|
@ -212,8 +212,18 @@ class StreamField(models.Field):
|
|||
)
|
||||
else:
|
||||
# When querying with JSONField features, the rhs might not be a StreamValue.
|
||||
# Note: when Django 4.2 is the minimum supported version, this can be removed
|
||||
# as the serialisation is handled in get_db_prep_value instead.
|
||||
return self.json_field.get_prep_value(value)
|
||||
|
||||
def get_db_prep_value(self, value, connection, prepared=False):
|
||||
if self.use_json_field and not isinstance(value, StreamValue):
|
||||
# When querying with JSONField features, the rhs might not be a StreamValue.
|
||||
# As of Django 4.2, JSONField value serialisation is handled in
|
||||
# get_db_prep_value instead of get_prep_value.
|
||||
return self.json_field.get_db_prep_value(value, connection, prepared)
|
||||
return super().get_db_prep_value(value, connection, prepared)
|
||||
|
||||
def from_db_value(self, value, expression, connection):
|
||||
if self.use_json_field and isinstance(expression, KeyTransform):
|
||||
# This could happen when using JSONField key transforms,
|
||||
|
|
Ładowanie…
Reference in New Issue