Fork me on GitHub
#sql
<
2023-09-15
>
Michael Gardner22:09:31

is it intentional that next.jdbc/with-transaction only supports literal maps for opts? When I try to pass a var, I get this: > opts - failed: map? at: [:binding :opts] spec: :next.jdbc.specs/opts-map

seancorfield22:09:27

Try it without instrumentation. I think that may just be a bug in the spec.

Michael Gardner22:09:59

afaik I'm not instrumenting 🤷

seancorfield22:09:34

Yes, you are. That spec check only happens if you have instrumentation enabled.

Michael Gardner22:09:09

I know, but there's nowhere in the code base that should be instrumenting right now. Going to have to track down what's doing that

seancorfield22:09:58

I've had a couple of reports over the years that a few of the specs in next.jdbc are overly strict. You're the first one to report with-transaction's spec tho'...

Michael Gardner22:09:57

wait, doesn't Clojure itself now check macro specs automatically?

seancorfield22:09:17

Only core stuff. Because of clojure.core.specs.

seancorfield22:09:32

Hmm, maybe you're right... I'm... surprised by that... I thought you needed to explicitly call instrument to turn on checking but it does look like macro expansion checks some level of fdef if it is present.

seancorfield22:09:05

Yup, confirmed!

Clojure 1.12.0-alpha4
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (s/fdef foo :args (s/cat :a int?))
user/foo
user=> (defmacro foo [a] `(* ~a ~a))
#'user/foo
user=> (foo 1)
1
user=> (foo "2")
Syntax error macroexpanding user/foo at (REPL:1:1).
"2" - failed: int? at: [:a]
user=> (let [x 1] (foo a))
Syntax error macroexpanding user/foo at (REPL:1:12).
a - failed: int? at: [:a]
user=>

seancorfield22:09:37

OK, I'll open a bug against next.jdbc to fix that -- and I'll double-check any other macros in there that have specs...

Michael Gardner22:09:45

that's a TIL for me too. And thank you!

seancorfield23:09:08

OK, fix is in https://clojars.org/com.github.seancorfield/next.jdbc/versions/1.3.999-SNAPSHOT (or you can depend on the develop branch via git deps).

gratitude 1
Michael Gardner23:09:46

awesome, thanks for the super-quick turnaround

seancorfield23:09:34

I'm embarrassed by both the bug and my misdiagnosis of your issue 😕

Michael Gardner23:09:03

no worries! Just glad I wasn't going crazy