update vexec to take a map of options (used to specify namespace)

this change is mainly to keep consistent with views.sql's vexec args
This commit is contained in:
Gered 2016-06-01 17:04:30 -04:00
parent 92486e54e9
commit eb00afa136
2 changed files with 12 additions and 12 deletions

View file

@ -46,14 +46,14 @@
Arguments are: Arguments are:
- db: a clojure.java.jdbc database connection - db: a clojure.java.jdbc database connection
- namespace (optional): a namespace that will be included in the hints sent out - action-map: the HoneySQL map for the insert/update/delete SQL query
- action-map: the HoneySQL map for the insert/update/delete SQL query"
([^Atom view-system db namespace action-map] Options are:
(let [results (execute-honeysql! db action-map) - namespace: a namespace that will be included in the hints sent out"
hsql-hint (hint namespace (query-tables action-map) hint-type)] [^Atom view-system db action-map & [{:keys [namespace] :as options}]]
(if-let [hints (:views-honeysql/hints db)] (let [results (execute-honeysql! db action-map)
(swap! hints conj hsql-hint) hsql-hint (hint namespace (query-tables action-map) hint-type)]
(put-hints! view-system [hsql-hint])) (if-let [hints (:views-honeysql/hints db)]
results)) (swap! hints conj hsql-hint)
([^Atom view-system db action-map] (put-hints! view-system [hsql-hint]))
(vexec! view-system db nil action-map))) results))

View file

@ -30,7 +30,7 @@
(deftest namespace-is-passed-along-to-hints-via-vexec (deftest namespace-is-passed-along-to-hints-via-vexec
(let [sql {:insert-into :example (let [sql {:insert-into :example
:values [{:field1 "test" :field2 "N" :field3 nil}]} :values [{:field1 "test" :field2 "N" :field3 nil}]}
result (vexec! test-view-system test-db :foobar sql)] result (vexec! test-view-system test-db sql {:namespace :foobar})]
(is (called-with-args? :jdbc/insert! test-db (:insert-into sql) (first (:values sql)))) (is (called-with-args? :jdbc/insert! test-db (:insert-into sql) (first (:values sql))))
(is (= :jdbc/insert!-return-value result)) (is (= :jdbc/insert!-return-value result))
(is (called-with-args? :views/put-hints! test-view-system [(views/hint :foobar #{:example} hint-type)])))) (is (called-with-args? :views/put-hints! test-view-system [(views/hint :foobar #{:example} hint-type)]))))