This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-01
Channels
- # adventofcode (170)
- # announcements (3)
- # babashka (1)
- # beginners (25)
- # cherry (1)
- # cider (3)
- # clj-kondo (5)
- # cljsrn (9)
- # clojure (27)
- # clojure-art (2)
- # clojure-europe (11)
- # clojure-nl (1)
- # clojure-norway (26)
- # clojure-sweden (2)
- # clojure-uk (5)
- # code-reviews (12)
- # component (8)
- # conjure (1)
- # data-science (2)
- # hyperfiddle (6)
- # malli (5)
- # off-topic (65)
- # overtone (34)
- # polylith (3)
- # re-frame (2)
- # reagent (2)
- # releases (3)
- # rum (1)
- # shadow-cljs (2)
- # slack-help (8)
- # sql (8)
- # squint (100)
- # thejaloniki (3)
- # tools-build (16)
- # vim (7)
- # yamlscript (1)
This is probably something trivial, but I can't seemingly find an answer to this. I'm using next.jdbc to access my sqlite DB. I use HoneySQL to generate SQL statements to execute. My DB tables and their columns are named in snake_case. Yet my Clojure code operates on :dash-separated-keywords. Is there a way to make next.jdbc/HoneySQL convert between the two name schemes automatically for each query and each result set?
Can you be a bit more specific about what exactly you're doing?
HoneySQL will turn :a-b
into a_b
:
user=> (sql/format '{select (a-b, c-d) from t-1 where (= a-b.x-y 42)})
["SELECT a_b, c_d FROM t_1 WHERE a_b.x_y = ?" 42]
so I imagine you're looking to turn a_b
in the result set back into :a-b
?Yep, that's right.
I actually prefer having the DB results match the DB table/columns so I can see that this is raw data from the DB but the next.jdbc
docs explain how to get kebab-case back -- Getting Started: https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.894/doc/getting-started#options--result-set-builders
(there's a lot of information in the Getting Started guide you will find useful)
Also described in the API docs: https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.894/api/next.jdbc#snake-kebab-opts
Thanks heaps! This seems to be exactly what I was looking for. How did I miss this? 😓 😇
A lot of folks read the docs bit seem to miss all sorts of "gems" -- I'd be happy to improve the docs if you have suggestions!