This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-06
Channels
- # announcements (3)
- # beginners (83)
- # calva (11)
- # cider (24)
- # cljdoc (2)
- # cljs-dev (1)
- # clojure (216)
- # clojure-berlin (1)
- # clojure-dev (18)
- # clojure-europe (8)
- # clojure-italy (5)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-spec (34)
- # clojure-uk (75)
- # clojuredesign-podcast (12)
- # clojurescript (33)
- # clojutre (13)
- # community-development (1)
- # core-async (38)
- # cursive (19)
- # datomic (28)
- # duct (3)
- # emacs (1)
- # events (5)
- # figwheel-main (3)
- # fulcro (93)
- # kaocha (20)
- # lambdaisland (2)
- # off-topic (40)
- # pathom (17)
- # pedestal (8)
- # quil (1)
- # re-frame (14)
- # reitit (19)
- # shadow-cljs (34)
- # sql (8)
- # tools-deps (6)
- # vim (1)
- # xtdb (8)
- # yada (18)
måning
Mornin'
Fun plans for the weekend?
The wife's away (in China) so I'll probably spend most of my weekend working on HoneySQL... and trying to finish the (long) "lessons learned" blog post I started about my takeaways from eight years of maintaining clojure.java.jdbc
...
Thanks. Any frustrations with it?
Not sure what you mean @U09LZR36F HoneySQL doesn't do camel casing...
Nope
user=> (require '[honeysql.helpers :refer :all] '[honeysql.core :as h])
WARNING: update already refers to: #'clojure.core/update in namespace: user, being replaced by: #'honeysql.helpers/update
nil
user=> (-> (select :*) (from :some-table) (h/format))
["SELECT * FROM some_table"]
user=> (-> (select :*) (from :some_table) (h/format))
["SELECT * FROM some_table"]
user=>
It converts -
to _
but you can turn that off.user=> (-> (select :*) (from :some-table) (h/format :allow-dashed-names? true :quoting :mysql))
["SELECT * FROM `some-table`"]
user=>
I know I can, but I find that kind of api design very frustrating. Maybe it's just me. I prefer the closest relationship between what I type and what happens possible.
If you don't ask for quoting, the -
is going to be illegal in most database tho', right?
(and "good morning, Dominic!" 🙂 )
I mostly agree with you tho'... this is why next.jdbc
's default is "as-is" (albeit qualified keywords) rather than clojure.java.jdbc
's somewhat weird default of forcing lower-case on columns.
Hahaha... well, much as I love MySQL, it's a weird, non-standard beast.
Like the table names are case-sensitive if the O/S is case-sensitive but column names are case-insensitive and even value equality on strings is case-insensitive (by default, at least on early versions).
I must admit, because we have some weird legacy conventions in our MySQL DB, I've started to adopt these as default options:
(def ^:private jdbc-options
"The default set of options to pass to next.jdbc so that we get
kebab-case identifiers and snake_case entities."
{:builder-fn rs/as-modified-maps
:column-fn ->snake_case
:label-fn ->kebab-case
:qualifier-fn ->kebab-case
:table-fn ->snake_case})
This doesn't help with all of our tables, but it makes our more recent decisions more tenable. We have a lot of legacy camelCase table and column names 😞 I hate our database to be honest!
Of course, if we were starting fresh, we'd probably use Datomic 🙂
I'm looking forward to a stable crux, a lot of my ideas are "oh, let's store this for later. Might be handy".
Let me ponder, nothing comes to mind at the moment (still a newcomer...). I suppose the only thing that would have helped is whether I can enable debug/trace logging of the SQL that is being flung out (but perhaps that is a log configuration?)
also, it wasn't clear, until I started used it, that the results that it returns are namespace qualified maps, had to read-and-re-read and try the documentation to discover that
You could always write your own logging wrapper for honeysql.core/format
-- since you have to call something to turn the data structure into SQL.
Not sure what you mean about the "namespace qualified maps" -- that doesn't sound like HoneySQL stuff?
Do you mean next.jdbc
returns namespace qualified maps by default? (I thought the docs for next.jdbc
made that pretty clear -- but suggestions for improvements are welcome!)
That's great to hear @U11EL3P9U -- I'll try not to break it with any future changes 😉
I love tiling window managers… Having tried almost all of them XMonad was my favourite. Having to use Amethyst on macos, which is a poor substitute for any of the proper ones.
Microsoft have released an open source version of PowerToys for Windows 10 which includes an interesting take on "window management"...
(I'm loving it for my use case)
Ha! once again I find myself regretting my previous use of optional params thus
(defn my-fn [param1 & {:keys [opt1 opt2]}]
becomes
(defn my-fn
([param1] (my-fn param1 nil))
([param1 {:keys [opt1 opt2]}]
...)
this is is recurring theme for me.
I almost always experience this same remorse after introducing optional parameters
I assume its not just me....
under what circumstances has optional params to be a good choice?
(If any)
well you could do (defn my-fn [param1 & [{:keys [opt1 opt2]}]] ...)
for a similar result
although i favour the dual-arity version, but only 'cos i find it easier to read and "easier to read" is partly a feature of familiarity, so it's not necessarily a particularly sound reason
i just ag
d over our codebase with (\ |\[)\&\
and found a couple of useful cases for rest-args
[2] proxy functions with [& args]
which forward all their args to another fn
but we don't have any use of the map destructure on rest-args - i really don't like it
There are times when you just want to shove args at a function, though to be honest I tend to do:
(defn my-fn [param1 {:keys [opt1 opt2] :as opts}]...)
(not that I’m certain it’s a good pattern, I just find it useful as I’m destructuring a map anyway)
I rarely make the opts actually optional and do as you did…
(defn my-fn
([param1] ...)
([param1 {:keys [opt1 opt2] :as opts}]...)
I definitely prefer multiple arity versions
I really really dislike twitter's resetting of my "show latest tweets" to "show top tweets"
I never want to see top tweets, only the latest, so I wish it wouldn't reset after a time
omfg CIDER with the shadow-cljs node-repl
is a real eye-opener
it's the cljs repl i've been waiting for forever
There are times when you just want to shove args at a function, though to be honest I tend to do:
(defn my-fn [param1 {:keys [opt1 opt2] :as opts}]...)
(not that I’m certain it’s a good pattern, I just find it useful as I’m destructuring a map anyway)
I rarely make the opts actually optional and do as you did…
(defn my-fn
([param1] ...)
([param1 {:keys [opt1 opt2] :as opts}]...)