This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-26
Channels
- # aleph (9)
- # announcements (10)
- # aws (1)
- # beginners (65)
- # calva (9)
- # cider (11)
- # clj-kondo (1)
- # cljdoc (61)
- # cljsrn (6)
- # clojars (2)
- # clojure (40)
- # clojure-austin (1)
- # clojure-belgium (1)
- # clojure-europe (4)
- # clojure-finland (1)
- # clojure-france (1)
- # clojure-italy (57)
- # clojure-nl (6)
- # clojure-spec (134)
- # clojure-uk (67)
- # clojuredesign-podcast (2)
- # clojurescript (40)
- # cursive (25)
- # datascript (1)
- # datomic (8)
- # events (1)
- # figwheel-main (18)
- # fulcro (36)
- # immutant (5)
- # jobs (5)
- # joker (3)
- # kaocha (41)
- # leiningen (4)
- # luminus (4)
- # off-topic (13)
- # onyx (8)
- # pedestal (2)
- # perun (7)
- # planck (2)
- # protorepl (9)
- # re-frame (3)
- # reagent (73)
- # reitit (5)
- # shadow-cljs (186)
- # sql (4)
- # vim (1)
- # yada (2)
when going over some code that uses next-jdbc/execute-one!
with a co-worker today, they had asked me if it would fail if used with a statement that returned more than one row. when digging into the implementation, the answer appears to be no. would this be a welcome contribution? or should I build that into my application layer instead?
I don't think that's an error - https://github.com/seancorfield/next-jdbc/blob/master/doc/getting-started.md#execute--execute-one says it can be used to return the first row of any result set. I can certainly think of places where it would be useful.
@peter.royal The intent is that you use execute-one!
if you either know you'll only get one row back or you want the first one and don't care about anything else. get-by-id
, which exists in clojure.java.jdbc
as well, returns the first match, for example. This is so you can rely on execute-one!
returning a hash map (or nil
if there are no matches), whereas execute!
will always return a vector of hash maps (and may be empty). That way you get some guarantees.