Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix issues with fix
  • Loading branch information
ibarrick committed Sep 16, 2019
commit fc7d9f4956610410195a8f1f1bbccc7a7843add6
14 changes: 7 additions & 7 deletions src/yesql/generate.clj
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@
["No database connection supplied to function '%s',"
"Check the docs, and supply {:connection ...} as an option to the function call, or globally to the defquery declaration."])
name))
(cond (and (= insert-handler jdbc-fn) (:hooks query-options) (:before-insert query-options))
(cond (and (= insert-handler jdbc-fn) (:hooks query-options) @(:hooks (:before-insert query-options)))
((:before-insert @(:hooks query-options)) args statement call-options)
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "delete" (lower-case (first (split (trim statement) #" ")))) (:before-delete query-options))
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "delete" (lower-case (first (split (trim statement) #" ")))) (:before-delete @(:hooks query-options)))
((:before-delete @(:hooks query-options)) args statement call-options)
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "update" (lower-case (first (split (trim statement) #" ")))) (:before-update query-options))
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "update" (lower-case (first (split (trim statement) #" ")))) (:before-update @(:hooks query-options)))
((:before-update @(:hooks query-options)) args statement call-options))
(let [ret (jdbc-fn connection
(rewrite-query-for-jdbc tokens args)
call-options)]
(cond (and (= insert-handler jdbc-fn) (:hooks query-options) (:after-insert query-options))
(cond (and (= insert-handler jdbc-fn) (:hooks query-options) (:after-insert @(:hooks query-options)))
((:after-insert @(:hooks query-options)) ret args statement call-options)
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "delete" (lower-case (first (split (trim statement) #" ")))) (:after-delete query-options))
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "delete" (lower-case (first (split (trim statement) #" ")))) (:after-delete @(:hooks query-options)))
((:after-delete @(:hooks query-options)) ret args statement call-options)
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "update" (lower-case (first (split (trim statement) #" ")))) (:after-update query-options))
(do (println "running after update hook") ((:after-update @(:hooks query-options)) ret args statement call-options)))
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "update" (lower-case (first (split (trim statement) #" ")))) (:after-update @(:hooks query-options)))
((:after-update @(:hooks query-options)) ret args statement call-options))
ret))))
[display-args generated-function] (let [named-args (if-let [as-vec (seq (mapv (comp symbol clojure.core/name)
required-args))]
Expand Down