This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-23
Channels
- # alda (1)
- # beginners (26)
- # boot (88)
- # carry (2)
- # cider (6)
- # clara (6)
- # cljs-dev (43)
- # cljsrn (14)
- # clojure (48)
- # clojure-belgium (2)
- # clojure-czech (4)
- # clojure-dev (1)
- # clojure-dusseldorf (7)
- # clojure-japan (1)
- # clojure-russia (55)
- # clojure-spec (65)
- # clojure-taiwan (1)
- # clojure-uk (28)
- # clojurescript (154)
- # cursive (5)
- # datomic (1)
- # editors (2)
- # emacs (29)
- # funcool (1)
- # jobs (3)
- # lambdaisland (5)
- # leiningen (1)
- # luminus (2)
- # new-channels (1)
- # off-topic (17)
- # om (18)
- # om-next (10)
- # onyx (24)
- # parinfer (14)
- # pedestal (4)
- # planck (3)
- # re-frame (69)
- # reactive (2)
- # reagent (3)
- # schema (2)
- # spacemacs (2)
- # sql (13)
- # vim (11)
hello folks, I am using honesql
and I was wondering if I can avoid honeysql.core/format
to transform keyword and instead leave them to the jdbc layer and thread them with my own extend-protocol jdbc/ISQLValue
You could re-implement honeysql.format.ToSql on clojure.lang.Keyword to be the identity fn I guess
I'd think pretty hard about introducing my own type tho
thanks @donaldball from what I am trying at the repl, it looks like the namespaced keyword is not handled
so I might have to do it
> (-> (insert-into :events)
(values [event]) ;; {:events/:type :events/chat-customer ...}
(returning :*)
sql/format)
;; => ["INSERT INTO events (type, nonce, payload) VALUES (chat_customer, ?, ( )) RETURNING *" 1142]
oh sorry about the indentation
oh now we are talking:
(somewhere)
(defn keyword-sql-str
[kw]
(if-let [nmspc (namespace kw)]
(str nmspc "/" (name kw))
(name kw)))
(extend-protocol sql/ToSql
clojure.lang.Keyword
(to-sql [x] (keyword-sql-str x)))
(-> (insert-into :events)
(values [event])
(returning :*)
sql/format)
;; => ["INSERT INTO events (events/type, events/nonce, events/payload) VALUES (events/chat-customer, ?, ( )) RETURNING *" 1142]
all transformed a strings, thanks @donaldball for pointing me in the right direction!
just need to figure out the column names
Note you’re probably going to lose all of the fancy “convert dotted keywords into function calls” niceties
oh yes I see that I am already kind of losing the column names...maybe at this point it is better for me to use jdbc
directly
spent some time on this now and there is no real easy way to round-trip, the jdbc/insert!
function does not seem to return the correct type for jdbc/result-set-read-column