[Django] #29473: Postgres JSONField escaping to infinity on each save

39 views
Skip to first unread message

Django

unread,
Jun 5, 2018, 2:22:25 PM6/5/18
to django-...@googlegroups.com
#29473: Postgres JSONField escaping to infinity on each save
-------------------------------------+-------------------------------------
Reporter: Laurynas | Owner: (none)
Riliskis |
Type: Bug | Status: new
Component: | Version: 2.0
contrib.postgres | Keywords: postgress
Severity: Normal | JSONFields
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
postgress JSONFields are escaping to infinity as you can see in the input
below. The same behavior is reproduced through the admin interface.

I commented in bug https://code.djangoproject.com/ticket/26110 but not
sure if the issue if the same.

{{{
import uuid
from django.db import models
from django.contrib.postgres.fields import JSONField

class PublishedConsent(models.Model):
uuid = models.UUIDField(
default=uuid.uuid4,
editable=False)
json = JSONField()
}}}

{{{
>>> p = JSONTest.objects.get(instance="4550d7f3a28c4081af5b3ff5ac62ab60")
>>> p.data
'{}'
>>> p.save()
>>> p = JSONTest.objects.get(instance="4550d7f3a28c4081af5b3ff5ac62ab60")
>>> p.data
'"{}"'
>>> p.save()
>>> p = JSONTest.objects.get(instance="4550d7f3a28c4081af5b3ff5ac62ab60")
>>> p.data
'"\\"{}\\""'
>>> p.save()
>>> p = JSONTest.objects.get(instance="4550d7f3a28c4081af5b3ff5ac62ab60")
>>> p.data
'"\\"\\\\\\"{}\\\\\\"\\""'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29473>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 5, 2018, 10:58:49 PM6/5/18
to django-...@googlegroups.com
#29473: Postgres JSONField escaping to infinity on each save
-------------------------------------+-------------------------------------
Reporter: Laurynas Riliskis | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 2.0
Severity: Normal | Resolution:
Keywords: postgress | Triage Stage:
JSONFields | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

You are using Django 2.0? I can't reproduce with this test case for
`tests/postgres_tests/test_json.py`:
{{{
def test_string(self):
instance = JSONModel(field='{}')
instance.save()
loaded = JSONModel.objects.get()
self.assertEqual(loaded.field, '{}')
loaded.save()
loaded = JSONModel.objects.get()
self.assertEqual(loaded.field, '{}')
}}}
Does that pass for you? Can you provide a failing test for Django's test
suite?

--
Ticket URL: <https://code.djangoproject.com/ticket/29473#comment:1>

Django

unread,
Jun 7, 2018, 1:36:45 PM6/7/18
to django-...@googlegroups.com
#29473: Postgres JSONField escaping to infinity on each save
-------------------------------------+-------------------------------------
Reporter: Laurynas Riliskis | Owner: (none)
Type: Bug | Status: closed
Component: contrib.postgres | Version: 2.0
Severity: Normal | Resolution: needsinfo

Keywords: postgress | Triage Stage:
JSONFields | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* status: new => closed
* resolution: => needsinfo


--
Ticket URL: <https://code.djangoproject.com/ticket/29473#comment:2>

Reply all
Reply to author
Forward
0 new messages