This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-01
Channels
- # aleph (1)
- # announcements (2)
- # aws (3)
- # bangalore-clj (1)
- # beginners (136)
- # boot (3)
- # calva (89)
- # cider (44)
- # cljdoc (1)
- # cljs-dev (31)
- # clojure (101)
- # clojure-europe (3)
- # clojure-italy (52)
- # clojure-nl (7)
- # clojure-spec (12)
- # clojure-uk (34)
- # clojurescript (62)
- # community-development (46)
- # cursive (25)
- # datomic (6)
- # duct (26)
- # events (6)
- # figwheel-main (4)
- # fulcro (25)
- # graphql (2)
- # jackdaw (4)
- # jukebox (3)
- # kaocha (57)
- # leiningen (31)
- # off-topic (3)
- # onyx (4)
- # other-languages (22)
- # pathom (18)
- # re-frame (9)
- # reitit (3)
- # shadow-cljs (60)
- # spacemacs (9)
- # speculative (22)
- # sql (39)
- # tools-deps (45)
- # vim (37)
@seancorfield So using update
fn I ran into maximum query limit
hmm wait
Caused by java.io.IOException Tried to send an out-of-range integer as a 2-byte value: 59540
(hi btw!)
Need more context to be able to help.
What SQL, what params, what code 🙂
"Psql" doesn't mean anything to me...
I use postgreSQL
I had this query in hugsql:
--- :name update-item :returning-execute :*
-update items as i set
- a = t.a
- , b = t.b
- , c = t.c
- , d = t.d
-from (values :t*:updated_items)
-as t(id, a, b, c, d)
-where i.id = t.id
-returning i.id, i.a, i.b, i.c, i.d
I've no idea what that SQL does, sorry. I don't use PostgreSQL. But that doesn't look like it should generate lots of bind variables to me.
Ok np. Then found this:
I don't see any result for that link (it's in French and seems to say I don't have permission to read it?).
Wow, that's terrible advice! That's not how the java.jdbc
API should be used at all 😞
db-do-commands
is for DDL, not SQL. db-do-prepared
is a low-level routine (that's intended to be called by other parts of the library).
Also found this: https://stackoverflow.com/a/49615541/1184248
It might help me if you explained what you are trying to do and what your question actually is?
Haha, my initial question was simply how can I return maps subsets after an UPDATE
Well, :return-keys
has nothing to do with updates, only inserts. So that explains that confusion 🙂
thanks!
If you're doing an insert, you can ask the JDBC driver to return specific generated keys/columns on some databases.
(otherwise it will return a result set based on whatever the JDBC driver returns)
Why so?
Most DBs, when you do an update, just return the number of rows updated.
yeah, that’s what I got too
Thanks you for your time @seancorfield
I've no idea what that exception was caused by since I don't know a) what SQL would be generated from that HugSQL file and b) how HugSQL would try to run that SQL -- both matter here.
execute!
supports :multi? true
for batched operations BTW (which I think might address what those StackOverflow Q&A seem to be about)
There are examples in the java.jdbc
tests of that, e.g.,
(let [counts (sql/execute!
db
["INSERT INTO fruit (name,appearance) VALUES (?,?)"
["Apple" "rosy"]
["Pear" "yellow"]
["Orange" "round"]]
{:multi? true})
I suspect an UPDATE ... RETURNING would also work there.(in next.jdbc
, there's a single, high-level execute!
function for handling everything -- it's a much, much simpler API than the current java.jdbc
offers -- but that's a ways off yet as I'm still spending a lot of "hammock time" on it)
re: next.jdbc that is promising! That was I nice read: https://clojureverse.org/t/next-jdbc-early-notes/3480/15
thank you Sean
Have a nice day!