使用postgres和jOOQ的全文搜索和变量绑定不起作用

Dri*_*ydt 6 java sql postgresql jooq

我正在尝试使用jOOQ在postgres数据库中进行全文搜索.以下行有效:

Result res = pgContext.select()
                      .from(products.PRODUCTS)
                      .where("to_tsvector(title || ' ' || description || ' ' || tags) @@ to_tsquery('" + query + "')")
                      .fetch();
Run Code Online (Sandbox Code Playgroud)

但是当我添加变量绑定时,为了防止SQL注入,我不再获得结果:

Result res = pgContext.select()
                      .from(products.PRODUCTS)
                      .where("to_tsvector(title || ' ' || description || ' ' || tags) @@ to_tsquery('?')", query)
                      .fetch();
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

谢谢,美好的一天

Dri*_*ydt 3

由于 @posz 没有将他的评论作为答案发布,并且已经有一段时间了,为了清楚起见,我将自己发布他的回复作为答案。

尝试... to_tsquery(?) ... -- 绑定标记?在文字中不起作用。