Opened 8 years ago
Closed 8 years ago
#27886 closed Bug (needsinfo)
Django contrib.postgres JSONField adds additonal quotes to a dictionary.
Reported by: | pypetey | Owned by: | |
---|---|---|---|
Component: | contrib.postgres | Version: | 1.10 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I have installed django-channels and django-cq library for async/background tasks.
JSONField from django.contrib.postgres.fields is used on the model.
And when I assign to function to do async stuff the django-cq library would be creating a task in the database.
The code is relatively simple - it creates a Task object in the database and it uses JSONField from contrib.postgres on signature field.
sig = to_signature(func, args, kwargs) if parent is None and previous: parent = previous.parent task = Task.objects.create(signature={}, parent=parent, previous=previous, **kw)
When I access task objcect directly then I get
task.__dict__ Out[2]: {'_parent_cache': None, '_previous_cache': None, '_state': <django.db.models.base.ModelState at 0x83fcfd0>, '_uncommitted_filefields': [], 'at_risk': 'N', 'details': {}, 'finished': None, 'force_chain': False, 'id': UUID('40e62169-f743-47a1-95ea-ebe57acc9f38'), 'last_retry': None, 'parent_id': None, 'previous_id': None, 'result_expiry': None, 'result_ttl': 1800, 'retries': 0, 'signature': {'args': (), 'func_name': 'apps.accounts.consumers.send_email', 'kwargs': {}}, 'started': None, 'status': 'P', 'submitted': datetime.datetime(2017, 2, 28, 13, 47, 46, 329656, tzinfo=<UTC>), 'waiting_on_id': None}
However, when I do refresh the instance from db by doing task.refresh_from_db()
and then task.__dict__
I will receive this variation which has completely different quoting on JSONField fields (signature and details)
Out[4]: {'_state': <django.db.models.base.ModelState at 0x83fcfd0>, '_uncommitted_filefields': [], 'at_risk': 'N', 'details': '{}', 'finished': None, 'force_chain': False, 'id': UUID('40e62169-f743-47a1-95ea-ebe57acc9f38'), 'last_retry': None, 'parent_id': None, 'previous_id': None, 'result_expiry': None, 'result_ttl': 1800, 'retries': 0, 'signature': '{"args": [], "kwargs": {}, "func_name": "apps.accounts.consumers.send_email"}', 'started': None, 'status': 'P', 'submitted': datetime.datetime(2017, 2, 28, 13, 47, 46, 329656, tzinfo=<UTC>), 'waiting_on_id': None}
What could be root cause of the problem? Is it a bug in django?
I use windows 10 pro, postgres 95, python 3.5 32bit
#25532 might be related.
Change History (3)
comment:1 by , 8 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 8 years ago
Description: | modified (diff) |
---|
comment:3 by , 8 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
There isn't enough information here to reproduce the issue. Please see TicketClosingReasons/UseSupportChannels for ways to get help with "is it a bug?" questions. Alternative, if you can provide a test case for
tests/postgres_tests/test_json.py
that demonstrates a problem, please reopen the ticket. Thanks.