seancorfield / next-jdbc

A modern low-level Clojure wrapper for JDBC-based access to databases.
https://cljdoc.org/d/com.github.seancorfield/next.jdbc/
Eclipse Public License 1.0
755 stars 90 forks source link

insert-multi! hashmap support + batch mode #206

Closed rschmukler closed 2 years ago

rschmukler commented 2 years ago

Updates insert-multi! to support taking hash maps in addition to rows and cols. Also introduces a :batch flag which will call execute-batch! instead of the standard execute!

Note: I didn't have all of the fixture databases (I dev'd against embedded postgres) available locally and it looks like CI doesn't run on PRs for first time contributors so it may be worth testing this locally before merging it.

seancorfield commented 2 years ago

That was fast -- thank you! I may do a little code-smithing on it (e.g., lifting the (if batch? 1 ..) condition out since the str/join and the repeat are not needed in batch mode) but that all looks solid.

seancorfield commented 2 years ago

Tested on SQL Server (with MS and jTDS drivers) and MySQL (with MySQL and MariaDB drivers). All passes.

Added a check that all the columns are the same for all hash maps in the sequence (and a test for that).

Updated the Friendly SQL Functions section of the docs with examples of the new functionality.

Thank you!