Opened 3 years ago
Last modified 3 years ago
#33086 closed Bug
Postgres Contrib ArrayField raises error on serialization with "django.core.serializers.json" — at Initial Version
Reported by: | Anudeep Samaiya | Owned by: | < anudeepsamaiya > |
---|---|---|---|
Component: | contrib.postgres | Version: | 3.2 |
Severity: | Normal | Keywords: | postgres, json |
Cc: | Anudeep Samaiya | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The encoder is not supported currently, which causes the serialization of uuid fields missing.
Current Implementation:
def value_to_string(self, obj): values = [] vals = self.value_from_object(obj) base_field = self.base_field for val in vals: if val is None: values.append(None) else: obj = AttributeSetter(base_field.attname, val) values.append(base_field.value_to_string(obj)) return json.dumps(values)
Suggested Implementation:
def value_to_string(self, obj, encoder=DjangoJSONEncoder): values = [] vals = self.value_from_object(obj) base_field = self.base_field for val in vals: if val is None: values.append(None) else: obj = AttributeSetter(base_field.attname, val) values.append(base_field.value_to_string(obj)) return json.dumps(values, cls=encoder)
Note:
See TracTickets
for help on using tickets.