1

Here is my current code:

class EntryManager(models.Manager):
   def with_documents(self):
       vector = SearchVector('title', weight='A') + \
                SearchVector('slug', weight='B') + \
                SearchVector('content', weight='C') + \
                SearchVector('category', weight='D') + \
                SearchVector(StringAgg('tags__slug', delimiter=' ')) + \
                SearchVector('chron_date')
       if SearchVector('chron_date') == "":
           SearchVector('chron_date') == None
       if SearchVector('clock') == "":
           SearchVector('clock') == None
       return self.get_queryset().annotate(document=vector)

Here is my error:

invalid input syntax for type date: ""
LINE 1: ...| to_tsvector(COALESCE("ktab_entry"."chron_date", ''))) AS "...

I first got this error on the prior version of my code, at which time I followed the advice posted here: http://kb.tableau.com/articles/issue/error-invalid-input-syntax-for-type-date-error-while-executing-the-query by adding the two if clauses at the end, but that didn't work. I have seen this answer on SO: Error on using copy Command in Postgres (ERROR: invalid input syntax for type date: "") but there are no spaces in my quotes. This question on SO invalid input syntax for type date: "" in django, postgresql? has no answer. FWIW, there actually is a value in both the chron_date and clock fields: 2017-11-02 & 14:41:00 respectively. I already tried changing datestyle() to no effect. I also added null=True on the models but still get the same error.

Django 1.11.5, Postgresql 9.4, Python 3.6 on Ubuntu 16.04

1 Answer 1

0

I am told PG FTS does not yet handle dates or times.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.