Fork me on GitHub
Joelle Wakim18:02:04

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

Joelle Wakim18:02:25

(j/insert-multi! db (keyword (rule :table)) (conj [] :id :eid :prop :val :process :tx) @records)


Are you on PostgreSQL?


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 -- I'll update that with a note about MySQL too.

Joelle Wakim18:02:22

Ok thank you, I will change it and will let you know if it works


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.

Joelle Wakim18:02:51

@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)

Joelle Wakim19:02:13

@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.