I am trying to do a full text search in a postgres database using jOOQ. The following line works:
Result res = pgContext.select()
.from(products.PRODUCTS)
.where("to_tsvector(title || ' ' || description || ' ' || tags) @@ to_tsquery('" + query + "')")
.fetch();
But when I add variable binding, to protect from SQL injection, I no longer get results:
Result res = pgContext.select()
.from(products.PRODUCTS)
.where("to_tsvector(title || ' ' || description || ' ' || tags) @@ to_tsquery('?')", query)
.fetch();
Any ideas?
Thanks and good day
Since @posz did not post his comment as an answer, and it has been quite a while, I'll post his reply as an answer myself for clarity.
Try ... to_tsquery(?) ... -- the binding mark ? won't work inside a literal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With