honeysql 2026-07-09

Anyway to achieve this ?

(defn tagged-events [uuids]
  (-> (sqlh/select :event.event_id :event.event_date)
      (sqlh/from [:webapp.event :event] )
      (sqlh/join :entity [(keyword "@>") :event.tagged_entities [:lift uuids]])
      (sql/format)))
(tagged-events ["5cb95e06-3d4d-4fd1-ad9d-4f2d44aa4a3d"])
;; => ["SELECT event.event_id, event.event_date FROM webapp.event AS event INNER JOIN entity ON @>(event.tagged_entities, ?)"
;;     ["5cb95e06-3d4d-4fd1-ad9d-4f2d44aa4a3d"]]
The @> operator shows at the start of the ON before the fields instead of between the fields like := would

You need to require the pg-ops ns (which provides symbols for the weird keywords, as well as registering them as operators): https://cljdoc.org/d/com.github.seancorfield/honeysql/2.7.1399/api/honey.sql.pg-ops

@seancorfield thanks I did actually find that, but I had not required, I now have

(:require [honey.sql :as sql]
            [honey.sql.helpers :as sqlh]
            [honey.sql.pg-ops :as sql-ops]
            [clojure.string :as str]))
and
(defn tagged-events [uuids]
  (-> (sqlh/select :event.event_id :event.event_date)
      (sqlh/from [:webapp.event :event] )
      (sqlh/join :entity [:at> :event.tagged_entities [:lift uuids]])
      (sql/format)))
(tagged-events ["5cb95e06-3d4d-4fd1-ad9d-4f2d44aa4a3d"])
;; => ["SELECT event.event_id, event.event_date FROM webapp.event AS event INNER JOIN entity ON AT>(event.tagged_entities, ?)"
;;     ["5cb95e06-3d4d-4fd1-ad9d-4f2d44aa4a3d"]]
So changed it to use :at> how ever the formatted sql still looks invalid, it looks like they shoudl auto register from the source, but its still not placing the string in the correct place, am I missing something else ?

at> as a symbol, not :at> as a keyword.

That ns defines vars containing the keywords.

From the pg-ops-test ns:

(testing "named ops"
    (is (= ["SELECT a @> b AS x"]
           (sql/format {:select [[[sut/at> :a :b] :x]]})))
    (is (= ["SELECT a <@ b AS x"]
           (sql/format {:select [[[sut/<at :a :b] :x]]})))
    (is (= ["SELECT a @?? b AS x"]
           (sql/format {:select [[[sut/at? :a :b] :x]]})))
    (is (= ["SELECT a @@ b AS x"]
           (sql/format {:select [[[sut/atat :a :b] :x]]}))))

doh, thanks @seancorfield thats working now, I did not notice it was registered with out the : but all looks good thanks for your time as always 🙂

👍🏻 1