From eb5bfef5854411e0d372b40842c58319768d077c Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Fri, 26 Jun 2020 22:47:44 -0700 Subject: [PATCH] Restore opts/:return-keys optimization for stmt-sql --- src/next/jdbc/result_set.clj | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/next/jdbc/result_set.clj b/src/next/jdbc/result_set.clj index 2a2edfc..321e63d 100644 --- a/src/next/jdbc/result_set.clj +++ b/src/next/jdbc/result_set.clj @@ -662,12 +662,13 @@ "Given a `Statement`, a SQL command, execute it and return a `ResultSet` if possible. We always attempt to return keys." ^ResultSet - [^Statement stmt ^String sql] + [^Statement stmt ^String sql opts] (if (.execute stmt sql) (.getResultSet stmt) - (try - (.getGeneratedKeys stmt) - (catch Exception _)))) + (when (:return-keys opts) + (try + (.getGeneratedKeys stmt) + (catch Exception _))))) (defn- reduce-stmt-sql "Execute the SQL command on the given `Statement`, attempt to get either @@ -678,7 +679,7 @@ a hash map containing `:next.jdbc/update-count` and the number of rows updated, with the supplied function and initial value applied." [^Statement stmt sql f init opts] - (if-let [rs (stmt-sql->result-set stmt sql)] + (if-let [rs (stmt-sql->result-set stmt sql opts)] (let [rs-map (mapify-result-set rs opts)] (loop [init' init] (if (.next rs) @@ -698,7 +699,7 @@ a hash map containing `:next.jdbc/update-count` and the number of rows updated, and fold that as a single element collection." [^Statement stmt sql n combinef reducef connectable opts] - (if-let [rs (stmt-sql->result-set stmt sql)] + (if-let [rs (stmt-sql->result-set stmt sql opts)] (let [rs-map (mapify-result-set rs opts) chunk (fn [batch] (#'r/fjtask #(r/reduce reducef (combinef) batch))) realize (fn [row] (datafiable-row row connectable opts))]