#30446: Automatically resolve Value's output_field for stdlib types.
-------------------------------------+-------------------------------------
     Reporter:  Ozan Gerdaneri       |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  SearchVector,        |             Triage Stage:  Accepted
  SearchVectorField , Value          |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * type:  Bug => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 Specifying an explicit `output_field` for `Value` should resolve your
 issue.

 {{{#!python
 value = Value(
     "a string to be indexed and inserted to search_vector field",
     output_field=models.TextField(),
 )
 AModel.objects.filter(pk=1).update(
     search_vector=SearchVector(value),
 )
 }}}

 I guess `Value._resolve_output_field` could be made smarter for some
 stdlib types such as `str`, `float`, `int`, `Decimal`, `date`, `datetime`
 so I'm tentatively accepting on this basis.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30446#comment:2>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.c78e2e218d50f7997802e05cc8af99eb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to