#31221: HStoreField returns str instead of dict during tests.
------------------------------------+--------------------------------------
Reporter: Michael Mulholland | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: hstore | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Ryan C. Schwiebert):
* keywords: => hstore
* status: closed => new
* resolution: invalid =>
Comment:
This has been happening in a web server of mine. It is not clear at all
what causes it to happen, but when starts happening it persists.
{{{
Django==2.2.13
python==3.5.2
psycopg2-binary==2.8.3
django-tastypie==0.14.3
}}}
The model in question has this field:
`entities = HStoreField(null=True, default=None)`
The input in question is `{"1": None}`
The traceback looks like this, triggered by an assertion that checks the
type of the field to make sure it is a dict:
{{{
returned a value for entities that was not a dict. It returned this:
"1"=>NULL.
Jun 22 14:09:22 uwsgi[2563]: Traceback (most recent call last):
Jun 22 14:09:22 uwsgi[2563]: File "/opt/venvs/test/lib/python3.5/site-
packages/tastypie/resources.py", line 227, in wrapper
Jun 22 14:09:22 uwsgi[2563]: response = callback(request, *args,
**kwargs)
Jun 22 14:09:22 uwsgi[2563]: File "/opt/venvs/test/lib/python3.5/site-
packages/tastypie/resources.py", line 476, in dispatch_detail
Jun 22 14:09:22 uwsgi[2563]: return self.dispatch('detail', request,
**kwargs)
Jun 22 14:09:22 uwsgi[2563]: File "/opt/venvs/test/lib/python3.5/site-
packages/tastypie/resources.py", line 499, in dispatch
Jun 22 14:09:22 uwsgi[2563]: response = method(request, **kwargs)
Jun 22 14:09:22 uwsgi[2563]: File "/opt/venvs/test/lib/python3.5/site-
packages/tastypie/resources.py", line 1383, in get_detail
Jun 22 14:09:22 uwsgi[2563]: obj =
self.cached_obj_get(bundle=basic_bundle,
**self.remove_api_resource_names(kwargs))
Jun 22 14:09:22 uwsgi[2563]: File "/opt/venvs/test/lib/python3.5/site-
packages/tastypie/resources.py", line 1202, in cached_obj_get
Jun 22 14:09:22 uwsgi[2563]: cached_bundle =
self.obj_get(bundle=bundle, **kwargs)
Jun 22 14:09:22 uwsgi[2563]: File "/opt/venvs/test/lib/python3.5/site-
packages/testpackage/frontend/api.py", line 2997, in obj_get
Jun 22 14:09:22 uwsgi[2563]: ruleData = self.getData(pk)
Jun 22 14:09:22 uwsgi[2563]: File "/opt/venvs/test/lib/python3.5/site-
packages/testpackage/frontend/api.py", line 2941, in getData
Jun 22 14:09:22 uwsgi[2563]: update = buildUpdate(entry, Display)
Jun 22 14:09:22 uwsgi[2563]: File "/opt/venvs/test/lib/python3.5/site-
packages/eventLogger.py", line 133, in buildUpdate
Jun 22 14:09:22 uwsgi[2563]: raise TypeError('Wrong entities data
type.')
}}}
I tested using the ORM in a manage.py shell session that recovering this
object, I was able to access the `entities` attribute and indeed get
`{"1": None}`
Restarting the wsgi server sometimes fixes it.
--
Ticket URL: <https://code.djangoproject.com/ticket/31221#comment:6>
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/070.c22bc86f2ef405caa67d5c4328f504f8%40djangoproject.com.