【发布时间】:2016-10-15 03:54:50
【问题描述】:
我正在尝试使用 jOOQ 在 postgres 数据库中进行全文搜索。以下行有效:
Result res = pgContext.select()
.from(products.PRODUCTS)
.where("to_tsvector(title || ' ' || description || ' ' || tags) @@ to_tsquery('" + query + "')")
.fetch();
但是当我添加变量绑定以防止 SQL 注入时,我不再得到结果:
Result res = pgContext.select()
.from(products.PRODUCTS)
.where("to_tsvector(title || ' ' || description || ' ' || tags) @@ to_tsquery('?')", query)
.fetch();
有什么想法吗?
谢谢你,美好的一天
【问题讨论】:
-
试试
... to_tsquery(?) ...——绑定标记?在文字中不起作用。 -
谢谢,就是这样。如此简单的修复。
-
@pozs:你应该从中创建一个答案!
标签: java sql postgresql jooq