Skip to content
This repository was archived by the owner on Apr 17, 2021. It is now read-only.

Commit dedfddc

Browse files
Merge pull request #25 from shopsmart/trans_mgmt_and_helpers_006
Modify the function declaration ordering to fix dependency issue
2 parents 994cca9 + 5cb743b commit dedfddc

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject com.github.shopsmart/clj-infrastructure "0.1.18"
1+
(defproject com.github.shopsmart/clj-infrastructure "0.1.19"
22
:description "Infrastructure helpers for AWS, database, etc."
33
:url "https://github.com/shopsmart/clj-infrastructure"
44

src/clj_infrastructure/db.clj

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,36 @@
669669
detail-map))
670670

671671

672+
(defn run-statement
673+
[conn {:keys [stmt-text exec-mode op-comment binds opt-map commit?] :as stmt-detail-map}]
674+
675+
"""
676+
Runs the statement represented by the supplied statement detail
677+
map.
678+
679+
Returns: The statement detail map updated with {:result result-data}
680+
"""
681+
682+
(log/info (str "Running statement: [" stmt-text "] ..."))
683+
(let [sql-params (concat [stmt-text] binds)]
684+
(when op-comment
685+
(log/info (str "Operation comment: " op-comment)))
686+
(let [updated-map
687+
(assoc-in stmt-detail-map [:result]
688+
(cond
689+
(= exec-mode DB_EXEC_MODE_QUERY)
690+
(do
691+
(log/debug "Issuing statement as query (results expected) ...")
692+
(clojure.java.jdbc/query conn sql-params opt-map))
693+
(= exec-mode DB_EXEC_MODE_EXEC)
694+
(do
695+
(log/debug "Issuing statement as execution (no results expected) ...")
696+
(clojure.java.jdbc/execute! conn sql-params opt-map))))]
697+
(when commit?
698+
(.commit (:connection conn)))
699+
updated-map)))
700+
701+
672702
(defn run-sql-stmts-in-transaction
673703
[conn-or-spec stmt-detail-vec]
674704

@@ -699,32 +729,3 @@
699729
(for [stmt-detail-map stmt-detail-vec]
700730
(run-statement conn stmt-detail-map))))))
701731

702-
703-
(defn run-statement
704-
[conn {:keys [stmt-text exec-mode op-comment binds opt-map commit?] :as stmt-detail-map}]
705-
706-
"""
707-
Runs the statement represented by the supplied statement detail
708-
map.
709-
710-
Returns: The statement detail map updated with {:result result-data}
711-
"""
712-
713-
(log/info (str "Running statement: [" stmt-text "] ..."))
714-
(let [sql-params (concat [stmt-text] binds)]
715-
(when op-comment
716-
(log/info (str "Operation comment: " op-comment)))
717-
(let [updated-map
718-
(assoc-in stmt-detail-map [:result]
719-
(cond
720-
(= exec-mode DB_EXEC_MODE_QUERY)
721-
(do
722-
(log/debug "Issuing statement as query (results expected) ...")
723-
(clojure.java.jdbc/query conn sql-params opt-map))
724-
(= exec-mode DB_EXEC_MODE_EXEC)
725-
(do
726-
(log/debug "Issuing statement as execution (no results expected) ...")
727-
(clojure.java.jdbc/execute! conn sql-params opt-map))))]
728-
(when commit?
729-
(.commit (:connection conn)))
730-
updated-map)))

0 commit comments

Comments
 (0)