Quick change to do-prepared* in internal.clj:
(defn do-prepared*
"Executes an (optionally parameterized) SQL prepared statement on the
open database connection. Each param-group is a seq of values for all of
the parameters."
[return-keys sql & param-groups]
(with-open [stmt (if return-keys
(.prepareStatement (connection*) sql
java.sql.Statement/RETURN_GENERATED_KEYS)
(.prepareStatement (connection*) sql))]
(if return-keys
(do
(doseq [param-group param-groups]
(dorun (map-indexed (fn [index value]
(.setObject stmt (inc index) value))
param-group)))
(transaction* (fn []
(.executeUpdate stmt)
(first (resultset-seq* (.getGeneratedKeys stmt))))))
(do
(doseq [param-group param-groups]
(dorun (map-indexed (fn [index value]
(.setObject stmt (inc index) value))
param-group))
(.addBatch stmt))
(transaction* (fn []
(let [rs (seq (.executeBatch stmt))]
(if return-keys (first (resultset-seq*
(.getGeneratedKeys stmt))) rs))))))))
> (with-connection db
(insert-record :temp {:parent (rand 42)}))
{:id 88, :parent 13}
> (with-connection db
(insert-records :temp {:parent (rand 42)} {:parent (rand
42)}))
({:id 89, :parent 7} {:id 90, :parent 33})
>
This probably breaks something else though; I haven't tested ...
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en