This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-20
Channels
- # aws (1)
- # babashka (68)
- # beginners (68)
- # braveandtrue (6)
- # calva (4)
- # cider (10)
- # clj-kondo (26)
- # clojure (76)
- # clojure-dev (18)
- # clojure-europe (1)
- # clojure-norway (25)
- # clojure-spec (8)
- # clojure-sweden (7)
- # clojure-uk (3)
- # clojuredesign-podcast (1)
- # clojurescript (11)
- # conjure (29)
- # cursive (31)
- # datomic (29)
- # emacs (12)
- # fulcro (29)
- # graphql (3)
- # helix (2)
- # hoplon (39)
- # hugsql (4)
- # malli (3)
- # off-topic (62)
- # pedestal (8)
- # re-frame (23)
- # reagent (14)
- # rewrite-clj (10)
- # shadow-cljs (18)
- # spacemacs (3)
- # sql (13)
- # xtdb (32)
Is it possible to set :table-fn
option globally in next.jdbc? Or I have to wrap all the Friendly SQL Functions
for that?
What I do at work is to have a def
at the top of my SQL namespace that has the default options I want in any/all next.jdbc
calls and just pass that as the last argument in each call.
Because next.jdbc
traffics in pure JDBC (Java) objects, there's no way to provide "global options" @somedude314
But I am working on a middleware/wrapper approach that would allow you to create something "connectable" that could carry additional options. It's tricky because it has to be done in a way that causes no overhead for folks not using it, and that it composes in reasonable ways.
Gotcha, I think I am just gonna wrap it for now. It's an opportunity to avoid passing connectable for the already non-pure function
Ah, you're already relying on the connectable as global state rather than passing it through the call chain?
(I would advise against that since it makes code harder to test and also ties you into a single datasource)
I was injecting it into the Ring's request object via a middleware then my handler was passing it to the hugsql/next.jdbc functions. I thought it would make my code simpler if I make the data source and next.jdbc options for insert!, update! optional
But I can see how that will make my handlers harder to test, won't do it. Thanks for the advice 🙂
Passing it through the Ring request is fine because it's an argument everywhere.
I thought you meant you had it as a global in the namespace where you were wrapping the next.jdbc
calls.