It is impossible to say 'search the full text index for nothing' - the equivalent of a divide by zero.
About the best I could do at the database level would be to return no results by doing the equivalent of:
if not query.strip():
return 'somecompiledsearchthatisreallyunlikelytoexist'::tsquery
Which sucks, because it is a hack and needlessly querying the database when what should really happen in this case is to show a "you didn't enter a query stoopid" alert.
This should really be handled at the application level, because the meaning of an empty query will depend on context (in some places it means everything, in some places it means nothing, in other places it will be an error).
Sounds like we should not be generating SQL using 'WHERE fti @@ ftq(%s)' % quote(query), but instead doing 'WHERE %s' % ftiQuery(query)
It is impossible to say 'search the full text index for nothing' - the equivalent of a divide by zero.
About the best I could do at the database level would be to return no results by doing the equivalent of:
if not query.strip(): archthatisreall yunlikelytoexis t'::tsquery
return 'somecompiledse
Which sucks, because it is a hack and needlessly querying the database when what should really happen in this case is to show a "you didn't enter a query stoopid" alert.
This should really be handled at the application level, because the meaning of an empty query will depend on context (in some places it means everything, in some places it means nothing, in other places it will be an error).
Sounds like we should not be generating SQL using 'WHERE fti @@ ftq(%s)' % quote(query), but instead doing 'WHERE %s' % ftiQuery(query)
>>> ftiQuery('hello')
u"fti @@ ftq('hello')"
>>> ftiQuery(' ')
u"1=1"
>>> ftiQuery(None)
u"1=1"