Automatically resolve Value's output_field for stdlib types.
Hi,
I have a model of AModel. AModel has a SearchVectorField named search_vector. I want to update this vector by indexing a string that is not in any other field.
from django.db.models import Value
from django.contrib.postgres.search import SearchVector
AModel.objects.filter(pk=1).update(search_vector=SearchVector(Value("a string to be indexed and inserted to search_vector field")))
This code generates this error:
FieldError: Cannot resolve expression type, unknown output_field
It seemed to be a bug since I found similar usages in forums..
Change History (20)
Summary: |
SerachVectorField cannot be updated pure string →
SerachVectorField cannot be updated with pure string
|
Summary: |
SerachVectorField cannot be updated with pure string →
Automatically resolve Value's output_field for stdlib types.
|
Triage Stage: |
Unreviewed →
Accepted
|
Type: |
Bug →
Cleanup/optimization
|
Owner: |
changed from nobody to Simon Charette
|
Status: |
new →
assigned
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Cc: |
Sergey Fedoseev added
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted →
Ready for checkin
|
Version: |
2.2 →
master
|
Resolution: |
→ fixed
|
Status: |
assigned →
closed
|
Specifying an explicit
output_field
forValue
should resolve your issue.I guess
Value._resolve_output_field
could be made smarter for some stdlib types such asstr
,float
,int
,Decimal
,date
,datetime
so I'm tentatively accepting on this basis.