From 67138deaef139cd3122b36a3bb520df65e144cd3 Mon Sep 17 00:00:00 2001 From: Levi Dixon Date: Wed, 19 Jul 2017 16:13:50 -0500 Subject: [PATCH 1/2] Modify the function declaration ordering to fix dependency issue --- src/clj_infrastructure/db.clj | 59 ++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/clj_infrastructure/db.clj b/src/clj_infrastructure/db.clj index 96bdab1..8c72da0 100644 --- a/src/clj_infrastructure/db.clj +++ b/src/clj_infrastructure/db.clj @@ -669,6 +669,36 @@ detail-map)) +(defn run-statement + [conn {:keys [stmt-text exec-mode op-comment binds opt-map commit?] :as stmt-detail-map}] + + """ + Runs the statement represented by the supplied statement detail + map. + + Returns: The statement detail map updated with {:result result-data} + """ + + (log/info (str "Running statement: [" stmt-text "] ...")) + (let [sql-params (concat [stmt-text] binds)] + (when op-comment + (log/info (str "Operation comment: " op-comment))) + (let [updated-map + (assoc-in stmt-detail-map [:result] + (cond + (= exec-mode DB_EXEC_MODE_QUERY) + (do + (log/debug "Issuing statement as query (results expected) ...") + (clojure.java.jdbc/query conn sql-params opt-map)) + (= exec-mode DB_EXEC_MODE_EXEC) + (do + (log/debug "Issuing statement as execution (no results expected) ...") + (clojure.java.jdbc/execute! conn sql-params opt-map))))] + (when commit? + (.commit (:connection conn))) + updated-map))) + + (defn run-sql-stmts-in-transaction [conn-or-spec stmt-detail-vec] @@ -699,32 +729,3 @@ (for [stmt-detail-map stmt-detail-vec] (run-statement conn stmt-detail-map)))))) - -(defn run-statement - [conn {:keys [stmt-text exec-mode op-comment binds opt-map commit?] :as stmt-detail-map}] - - """ - Runs the statement represented by the supplied statement detail - map. - - Returns: The statement detail map updated with {:result result-data} - """ - - (log/info (str "Running statement: [" stmt-text "] ...")) - (let [sql-params (concat [stmt-text] binds)] - (when op-comment - (log/info (str "Operation comment: " op-comment))) - (let [updated-map - (assoc-in stmt-detail-map [:result] - (cond - (= exec-mode DB_EXEC_MODE_QUERY) - (do - (log/debug "Issuing statement as query (results expected) ...") - (clojure.java.jdbc/query conn sql-params opt-map)) - (= exec-mode DB_EXEC_MODE_EXEC) - (do - (log/debug "Issuing statement as execution (no results expected) ...") - (clojure.java.jdbc/execute! conn sql-params opt-map))))] - (when commit? - (.commit (:connection conn))) - updated-map))) From 5cb743ba4f6bc0dae6a52d58736ed08cb39b3004 Mon Sep 17 00:00:00 2001 From: Levi Dixon Date: Wed, 19 Jul 2017 16:14:38 -0500 Subject: [PATCH 2/2] Increment version --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 056088d..4a2547c 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject com.github.shopsmart/clj-infrastructure "0.1.18" +(defproject com.github.shopsmart/clj-infrastructure "0.1.19" :description "Infrastructure helpers for AWS, database, etc." :url "https://github.com/shopsmart/clj-infrastructure"