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

Comment (by Baptiste Mispelon):

 Initially, I thought that adding an explicit `Cast` (using
 `update(name=Cast(F('data__name'), CharField()))`) might solve the issue,
 but the test still fails in the same way.

 I got it to work using `KeyTextTransform` (which doesn't seem to be
 documented based on a quick `git grep`):
 `update(name=KeyTextTransform('name', 'data'))`.

 Adding to my confusion was the fact that this behavior doesn't appear when
 using `annotate`: `annotate(dataname=F('data__name'))` correctly yields
 `django` without the extra quotes.


 I'm not sure if this is really a bug or how fixable it is (I don't see how
 Django could guess that it should use `KeyTextTransform` over
 `KeyTransform`) but silently adding extra `"` seems pretty bad.
 Having `KeyTransform/KeyTextTransform` documented could help, though I'm
 not sure if I would have discovered their existence even if they were.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32491#comment:1>
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/067.6b61a435e15cb1ada16d60182294d464%40djangoproject.com.

Reply via email to