2017-11-04 212 views
1

這裏是我當前的代碼:Django的PostgreSQL的全文搜索時間輸入類型錯誤

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) 

這是我的錯誤:

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

我第一次對之前版本的這個錯誤我的代碼,在那個時候,我遵循了這裏發佈的建議:http://kb.tableau.com/articles/issue/error-invalid-input-syntax-for-type-date-error-while-executing-the-query,在最後加上了兩個if子句,但那不起作用。我在SO:Error on using copy Command in Postgres (ERROR: invalid input syntax for type date: "")上看到過這個答案,但我的引號中沒有空格。 SO invalid input syntax for type date: "" in django, postgresql?上的這個問題沒有答案。 FWIW,chron_date和clock字段中實際上都有一個值:2017-11-02 & 14:41:00分別。我已經試過改變datestyle()不起作用。我還在模型上添加了null = True,但仍然出現相同的錯誤。

的Django 1.11.5和PostgreSQL 9.4,Python的3.6在Ubuntu 16.04

回答

0

我告訴PG FTS還沒有處理的日期或時間。

相關問題