diff --git a/CHANGELOG.md b/CHANGELOG.md index b004a2a..e2d6037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Only accretive/fixative changes will be made from now on. * 1.3.next in progress + * Fix [#232](https://github.com/seancorfield/next-jdbc/issues/232) by using `as-cols` in `insert-multi!` SQL builder. Thanks to @changsu-farmmorning for spotting that bug! * Fix [#229](https://github.com/seancorfield/next-jdbc/issues/229) by adding `next.jdbc.connect/uri->db-spec` which converts a URI string to a db-spec hash map; in addition, if `DriverManager/getConnection` fails, it assumes it was passed a URI instead of a JDBC URL, and retries after calling that function and then recreating the JDBC URL (which should have the effect of moving the embedded user/password credentials into the properties structure instead of the URL). * Address [#228](https://github.com/seancorfield/next-jdbc/issues/228) by adding `PreparedStatement` caveat to the Oracle **Tips & Tricks** section. * Add `on-connection` to exported `clj-kondo` configuration. diff --git a/src/next/jdbc/sql/builder.clj b/src/next/jdbc/sql/builder.clj index b067dfa..7afa956 100644 --- a/src/next/jdbc/sql/builder.clj +++ b/src/next/jdbc/sql/builder.clj @@ -150,9 +150,8 @@ (assert (seq cols) "cols may not be empty") (assert (seq rows) "rows may not be empty") (let [table-fn (:table-fn opts identity) - column-fn (:column-fn opts identity) batch? (:batch opts) - params (str/join ", " (map (comp column-fn name) cols)) + params (as-cols cols opts) places (as-? (first rows) opts)] (into [(str "INSERT INTO " (table-fn (safe-name table)) " (" params ")" @@ -165,6 +164,12 @@ (if batch? identity cat) rows))) +(comment + (as-cols [:aa :bb :cc] {}) + (for-insert-multi :table [:aa :bb :cc] [[1 2 3] [4 5 6]] + {:table-fn str/upper-case :column-fn str/capitalize}) + ) + (defn for-order-col "Given a column name, or a pair of column name and direction, return the sub-clause for addition to `ORDER BY`."