|
@@ -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,
|