I’m using Postgres and have a field that includes large text fields. I want to find the entries that include question marks in the text (indicating questions in the text), but no amount of “?”, “??”, “/?”, “//?”, or anything else has worked for me. Anyone solved this issue?
scraper.db.core> (jdbc/query *db* "SELECT * FROM conversations WHERE full_text @@ to_tsquery('?')")
()
Use two question marks, one as placeholder in the query and the other as verbatim value in the query parameters
(jdbc/query db [“SELECT * from foo WHERE foo
.x
LIKE ?” “%?%”])
Well, I feel stupid. I think it was the % that was throwing me off, as they aren’t standard regexp syntax and I didn’t know about them.
(require '[honeysql.core :as sql]
(defn dbr [s] (jdbc/query *db* s))
(-> {:select [:*] :from [:conversations] :where [:like :full_text "%?%"]} sql/format dbr)
Thanks!
Note, the % is not regex — it’s for the SQL LIKE clause.
1 Like