This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-25
Channels
- # adventofcode (3)
- # aleph (24)
- # architecture (8)
- # beginners (53)
- # boot (34)
- # cider (7)
- # clara (68)
- # cljs-dev (6)
- # cljsrn (3)
- # clojars (10)
- # clojure (71)
- # clojure-germany (2)
- # clojure-italy (10)
- # clojure-nl (25)
- # clojure-serbia (4)
- # clojure-spec (13)
- # clojure-uk (48)
- # clojurescript (31)
- # core-async (62)
- # cursive (13)
- # datomic (4)
- # duct (76)
- # editors (4)
- # fulcro (2)
- # immutant (1)
- # instaparse (1)
- # jobs (1)
- # lein-figwheel (1)
- # mount (1)
- # off-topic (12)
- # onyx (8)
- # re-frame (10)
- # reagent (84)
- # reitit (2)
- # ring (2)
- # shadow-cljs (159)
- # spacemacs (2)
- # specter (17)
- # sql (14)
- # tools-deps (10)
- # yada (15)
@seancorfield Thanks! I was thinking about execute!
but it was night and my head was working badly. Will try it soon,
@jahson If you run into any problems, let me know.
Support for :return-keys
in execute!
is a fairly recent addition...
I’m using latest version of clojure.java.jdbc
and everything is working perfectly.
dev=> (jdbc/execute! db ["insert into tbl(a, b, c, d, e, f) values (?, ?, ?, '', 0, now()) on duplicate key update id=last_insert_id(id);" 1 123 "#123"] {:return-keys true})
{:generated_key 7} ;; row was created
dev=> (jdbc/execute! db ["insert into tbl(a, b, c, d, e, f) values (?, ?, ?, '', 0, now()) on duplicate key update id=last_insert_id(id);" 1 123 "#123"] {:return-keys true})
{:generated_key 7} ;; duplicate key => last_insert_id
Nice!
Hi folks, I'm curious about should I use namespaced keyword with java.jdbc
or other sql libraries like hugsql
, honeysql
. I know there's a way to transform the result and input, I wonder if this is a good idea. It's likely there's no library have built-in support for this.
@doglooksgood Walkable supports namespaced keywords out of the box https://github.com/walkable-server/walkable
behind the scene, Walkable makes queries like this select "column" as "table/column" from "table"
@doglooksgood clojure.java.jdbc
explicitly supports creation of namespaced keywords via :qualifier
and sending in qualified keywords to insert!
etc should work out of the box, so I'm not sure I understand your question.
@myguidingstar @seancorfield thanks, I'll take a look
There aren't any examples of using qualified keywords with insert!
in the test suite but there are several examples using :qualifier
like this https://github.com/clojure/java.jdbc/blob/master/src/test/clojure/clojure/java/jdbc_test.clj#L998
@seancorfield thanks!
Updated one of the tests to use qualified keywords for table and column names for create-table-ddl
and insert-multi!
(as well as :qualifier
in a query
): https://github.com/clojure/java.jdbc/blob/master/src/test/clojure/clojure/java/jdbc_test.clj#L1061