#32491: Updating a field based on a JSONField's sub-value adds extra quotes
[postgres]
-------------------------------------+-------------------------------------
     Reporter:  Baptiste Mispelon    |                    Owner:
                                     |  YashRaj1506
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by YashRaj1506):

 So it was mentioned that it works well with  annotate but when i am trying
 to do some tests, it adds a ' " ' after django, so i get ->  'django"'

 {{{
  class ReproductionTestCase(TestCase):
      def test_issue_update(self):
          JSONNamedModel.objects.create(data={'name': 'django"'})
          queryset =
 JSONNamedModel.objects.annotate(dataname=F('data__name'))
          self.assertEqual([obj.dataname for obj in queryset], ['django'])
 }}}

 this is the result on the terminal for the above mentioned testcase:

 {{{
 ======================================================================
 FAIL: test_issue_update
 (users.tests.ReproductionTestCase.test_issue_update)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/home/yash/Desktop/django-trial/trial/users/tests.py", line 20, in
 test_issue_update
     self.assertEqual([obj.dataname for obj in queryset], ['django'])
 AssertionError: Lists differ: ['django"'] != ['django']

 First differing element 0:
 'django"'
 'django'

 - ['django"']
 ?         -

 + ['django']

 ----------------------------------------------------------------------
 Ran 1 test in 0.002s

 FAILED (failures=1)
 Destroying test database for alias 'default'...
 }}}

 so ig the issue still persists from the annotate side too.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/32491#comment:8>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070193fd7222c3-cc184f08-9ffd-452d-acdf-3b4c9633ba7c-000000%40eu-central-1.amazonses.com.

Reply via email to