This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-07
Channels
- # announcements (35)
- # beginners (80)
- # boot (1)
- # calva (4)
- # cider (33)
- # cljdoc (40)
- # clojars (3)
- # clojure (95)
- # clojure-berlin (2)
- # clojure-europe (4)
- # clojure-italy (28)
- # clojure-nl (2)
- # clojure-seattle (1)
- # clojure-serbia (1)
- # clojure-spec (74)
- # clojure-uk (71)
- # clojurescript (29)
- # core-async (1)
- # cursive (80)
- # data-science (4)
- # datomic (17)
- # duct (75)
- # emacs (4)
- # figwheel-main (5)
- # fulcro (3)
- # jackdaw (1)
- # java (1)
- # jobs-discuss (20)
- # off-topic (32)
- # parinfer (2)
- # pathom (23)
- # re-frame (26)
- # reagent (25)
- # rum (6)
- # shadow-cljs (122)
- # speculative (4)
- # sql (17)
- # testing (7)
- # yada (8)
Hello @seancorfield, I am trying to insert a batch entry using insert-multi! fn but is not doing it in one single insert statement. Can you assist please, thank you
(j/insert-multi! db (keyword (rule :table)) (conj [] :id :eid :prop :val :process :tx) @records)
Are you on PostgreSQL?
No, MySQL
Then you probably need to specify :rewriteBatchedStatements true
in your db-spec
so that MySQL handles the batched insert correctly. PostgreSQL has a similar issue @joelle.wakim
Here's the JIRA issue for PostgreSQL https://dev.clojure.org/jira/browse/JDBC-174 -- I'll update that with a note about MySQL too.
Ok thank you, I will change it and will let you know if it works
Note that MySQL's version has been pretty buggy in the past https://bugs.mysql.com/bug.php?id=68562 (fixed), https://bugs.mysql.com/bug.php?id=34093 (fixed), et al. Also, frustration expressed here https://stackoverflow.com/questions/48100030/why-does-rewritebatchedstatements-default-to-false-for-mysql-connector-j
In particular, be aware of the caveats given in the answer to that SO issue.
(this sort of thing is horribly DB-specific, unfortunately, in the same way that streaming of result sets is also very DB-specific)
I've updated JDBC-174 -- I'll try to figure out a better way to handle this in next.jdbc
but the rewritten SQL that PostgreSQL/MySQL produce here is not accepted by all databases, which is why java.jdbc
tries to do things the way it does today.
@seancorfield I changed the db-spec map and added :rewriteBatchedStatements true, but the code is still writing multiple insert statements and not one single statement, could the issue be something else? Thanks
@joelle.wakim No idea. Unfortunately each database driver has its quirks. Feel free to add repro steps to JDBC-174 (linked above) and I'll try to take a look when I get some time.
(also add notes of how you confirming that you get multiple inserts and information about how many rows you're trying to insert etc)
@seancorfield ok thank you, I can see the multiple insert statements from Mysql log file. Just a question does the same apply to MariaDB?
In theory, this is purely a feature of the database driver rather than the underlying database that you are connecting to. That said, if you use a driver that is not compatible with the database, you'll run into problem.
@joelle.wakim Could you add the dependencies/versions you're using to that ticket too pls? So I know what version of the driver to attempt to repro with.