relevancy check now matches type and namespace. add namespace to vexec!

previously the relevancy check and vexec! were using a hint's
namespace property as what we're now calling "type". i think this is
a lot more straightforward.
This commit is contained in:
Gered 2016-05-20 18:16:52 -04:00
parent c77be6aea8
commit 37e49d9730
2 changed files with 14 additions and 8 deletions

View file

@ -6,6 +6,8 @@
[clojure.tools.logging :refer [error]]
[clojure.java.jdbc :as j]))
(def hint-type :sql-table-name)
(defn send-hints!
[hints]
((:put-hints-fn @view-system) hints))
@ -38,10 +40,12 @@
Arguments are:
- db: a clojure.java.jdbc database with fid field
- action-map: the HoneySQL map for the insert/update/delete action"
[db action-map]
(let [results (execute-honeysql! db action-map)
hsql-hint (hint :views/honeysql (query-tables action-map))]
(if-let [hints (:hints db)]
(swap! hints conj hsql-hint)
(send-hints! [hsql-hint]))
results))
([db namespace action-map]
(let [results (execute-honeysql! db action-map)
hsql-hint (hint namespace (query-tables action-map) hint-type)]
(if-let [hints (:hints db)]
(swap! hints conj hsql-hint)
(send-hints! [hsql-hint]))
results))
([db action-map]
(vexec! db nil action-map)))

View file

@ -1,6 +1,7 @@
(ns views.honeysql.view
(:require
[views.protocols :refer :all]
[views.honeysql.core :refer [hint-type]]
[views.honeysql.util :refer [query-tables]]
[honeysql.core :as hsql]
[clojure.set :refer [intersection]]
@ -18,7 +19,8 @@
data))
(relevant? [_ namespace parameters hints]
(let [tables (query-tables (apply query-fn parameters))
nhints (filter #(= :views/honeysql (:namespace %)) hints)]
nhints (filter #(and (= namespace (:namespace %))
(= hint-type (:type %))) hints)]
(boolean (some #(not-empty (intersection (:hint %) tables)) nhints)))))
(defn view