Merge pull request #233 from seancorfield:seancorfield/issue232

Column is not quote escaped.
This commit is contained in:
Sean Corfield 2022-11-04 20:35:49 -07:00 committed by GitHub
commit 06f9b7908c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -3,6 +3,7 @@
Only accretive/fixative changes will be made from now on. Only accretive/fixative changes will be made from now on.
* 1.3.next in progress * 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). * 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. * 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. * Add `on-connection` to exported `clj-kondo` configuration.

View file

@ -150,9 +150,8 @@
(assert (seq cols) "cols may not be empty") (assert (seq cols) "cols may not be empty")
(assert (seq rows) "rows may not be empty") (assert (seq rows) "rows may not be empty")
(let [table-fn (:table-fn opts identity) (let [table-fn (:table-fn opts identity)
column-fn (:column-fn opts identity)
batch? (:batch opts) batch? (:batch opts)
params (str/join ", " (map (comp column-fn name) cols)) params (as-cols cols opts)
places (as-? (first rows) opts)] places (as-? (first rows) opts)]
(into [(str "INSERT INTO " (table-fn (safe-name table)) (into [(str "INSERT INTO " (table-fn (safe-name table))
" (" params ")" " (" params ")"
@ -165,6 +164,12 @@
(if batch? identity cat) (if batch? identity cat)
rows))) 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 (defn for-order-col
"Given a column name, or a pair of column name and direction, "Given a column name, or a pair of column name and direction,
return the sub-clause for addition to `ORDER BY`." return the sub-clause for addition to `ORDER BY`."