#34500: use annotate return feild, Error capture does not work
-------------------------------------+-------------------------------------
Reporter: ajinwu | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords: json decode
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
when I use this sql
return data
testcase
{{{
#!div style="font-size: 80%"
{{{#!python
data = table.objects.annotate(
array_length=Func(F('feild'), function='jsonb_array_length')
).filter(array_length__gt=1).only("feild")[:5]
print(data.query)
for i in data:
print(model_to_dict(i))
}}}
}}}
sqldata
{{{
#!div style="font-size: 80%"
{{{#!python
data = [[1, '[{"key": "value"}]', 1]]
}}}
}}}
but when feild use from_db_value function, Error capture has no effect,
because json load int data, and can not return value
{{{
#!div style="font-size: 80%"
{{{#!python
try:
return json.loads(value, cls=self.decoder)
except json.JSONDecodeError:
return value
}}}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34500>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701878e2e9631-d05c0474-d6c0-4659-af33-7b1218e9904e-000000%40eu-central-1.amazonses.com.