Opened 6 years ago
Last modified 6 years ago
#29582 closed Bug
SearchVector doesn't support querying non-text fields — at Version 1
Reported by: | mickaelmarin | Owned by: | nobody |
---|---|---|---|
Component: | contrib.postgres | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I try to implement autocomplete on my place table that look like below:
class Place(models.Model): name = models.CharField(max_length=80, blank=True) num = models.IntegerField(null=True) street = models.CharField(max_length=100, blank=True) postal_code = models.IntegerField(null=True) district = models.CharField(max_length=30, blank=True) city=models.CharField(max_length=30, blank=True) country = models.CharField(max_length=30, blank=True) domicile = models.BooleanField(default=False) def __str__(self): address = "{0}, {1}, {2}, {3}".format(self.num, self.street, self.postal_code, self.city, self.country) return address
and in my function that return the result for display my address on frontend is like (self.q is a GET param from ajax call):
qs = Place.objects.all() qs.annotate(search=SearchVector('street', 'country','city', 'num')).filter(search__icontains=self.q)
I have this error when the ajax call run:
File "/opt/coupdepouce/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.DataError: invalid input syntax for integer: "" LINE 1: ...city", '') || ' ' || COALESCE("user_place"."num", '')) AS "s...
Change History (1)
comment:1 by , 6 years ago
Component: | Uncategorized → contrib.postgres |
---|---|
Description: | modified (diff) |
Summary: | postgresql SearchVector error when try to add integerfield to it → SearchVector doesn't support querying non-text fields |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
The problem seems to be hardcoded
Value('')
, regardless of the field type. I'm not sure what the proper resolution is.