dbはPostgreSQLです。このようなパラメータを使用してクエリを実行しようとすると
cursor.execute("""
SELECT u.username, up.description,
ts_rank_cd(to_tsvector(coalesce(username,'')|| coalesce(description,'')) , to_tsquery('%s')) as rank
FROM auth_user u INNER JOIN pm_core_userprofile up on u.id = up.user_id
WHERE to_tsvector(coalesce(username,'')|| coalesce(description,'')) @@ to_tsquery('%s')
ORDER BY rank DESC;
""", ["hello","hello"])
DjangoはProgrammingErrorについて文句を言い、パラメータ(この例では「hello 」)またはその近くに構文エラーを追加します。エラーの原因となるDjangoで生成されたSQLステートメントの一部は次のとおりです。
to_tsquery('E'hello'')
コピーしてpostgreSQLシェルに貼り付けても、構文エラーが発生します。「E」の部分を省略しても機能します。私はそれをどうすればいいですか?