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:
- 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"
([^Atom view-system db namespace action-map]
- action-map: the HoneySQL map for the insert/update/delete SQL query
Options are:
- namespace: a namespace that will be included in the hints sent out"
[^Atom view-system db action-map & [{:keys [namespace] :as options}]]
(let [results (execute-honeysql! db action-map)
hsql-hint (hint namespace (query-tables action-map) hint-type)]
(if-let [hints (:views-honeysql/hints db)]
(swap! hints conj hsql-hint)
(put-hints! view-system [hsql-hint]))
results))
([^Atom view-system db action-map]
(vexec! view-system db nil action-map)))

View file

@ -30,7 +30,7 @@
(deftest namespace-is-passed-along-to-hints-via-vexec
(let [sql {:insert-into :example
: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 (= :jdbc/insert!-return-value result))
(is (called-with-args? :views/put-hints! test-view-system [(views/hint :foobar #{:example} hint-type)]))))