core: defprotocol accepts docstring + keyword options (honeysql)

Clojure's defprotocol takes an optional docstring and leading keyword
options (:extend-via-metadata true) before the signatures; jolt's macro
fed the option keyword to (first sig). honeysql declares its InlineValue
protocol exactly that way — with the fix, all four honeysql namespaces
load unmodified from git and the formatter produces correct sqlvecs for
selects/inserts/updates/deletes/joins/:inline. Listed in libraries.md.
This commit is contained in:
Yogthos 2026-06-11 22:56:12 -04:00
parent b2c9970583
commit e1a6d77b0c
3 changed files with 19 additions and 1 deletions

View file

@ -295,7 +295,15 @@
;; instead of evaluating its fields. methods is a {kw {:name str}} map (only :name
;; is consulted). Each method is a thin dispatch fn over protocol-dispatch.
(defmacro defprotocol [pname & sigs]
(let [methods (reduce (fn [m sig]
;; Clojure's defprotocol takes an optional docstring and leading keyword
;; options (:extend-via-metadata true, honeysql uses it) before the method
;; signatures — drop them (metadata extension is a JVM dispatch detail).
(let [sigs (loop [s sigs]
(cond
(string? (first s)) (recur (rest s))
(keyword? (first s)) (recur (rest (rest s)))
:else s))
methods (reduce (fn [m sig]
(assoc m (keyword (name (first sig))) {:name (name (first sig))}))
{} sigs)]
`(do