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:
parent
c77be6aea8
commit
37e49d9730
|
@ -6,6 +6,8 @@
|
||||||
[clojure.tools.logging :refer [error]]
|
[clojure.tools.logging :refer [error]]
|
||||||
[clojure.java.jdbc :as j]))
|
[clojure.java.jdbc :as j]))
|
||||||
|
|
||||||
|
(def hint-type :sql-table-name)
|
||||||
|
|
||||||
(defn send-hints!
|
(defn send-hints!
|
||||||
[hints]
|
[hints]
|
||||||
((:put-hints-fn @view-system) hints))
|
((:put-hints-fn @view-system) hints))
|
||||||
|
@ -38,10 +40,12 @@
|
||||||
Arguments are:
|
Arguments are:
|
||||||
- db: a clojure.java.jdbc database with fid field
|
- db: a clojure.java.jdbc database with fid field
|
||||||
- action-map: the HoneySQL map for the insert/update/delete action"
|
- action-map: the HoneySQL map for the insert/update/delete action"
|
||||||
[db action-map]
|
([db namespace action-map]
|
||||||
(let [results (execute-honeysql! db action-map)
|
(let [results (execute-honeysql! db action-map)
|
||||||
hsql-hint (hint :views/honeysql (query-tables action-map))]
|
hsql-hint (hint namespace (query-tables action-map) hint-type)]
|
||||||
(if-let [hints (:hints db)]
|
(if-let [hints (:hints db)]
|
||||||
(swap! hints conj hsql-hint)
|
(swap! hints conj hsql-hint)
|
||||||
(send-hints! [hsql-hint]))
|
(send-hints! [hsql-hint]))
|
||||||
results))
|
results))
|
||||||
|
([db action-map]
|
||||||
|
(vexec! db nil action-map)))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns views.honeysql.view
|
(ns views.honeysql.view
|
||||||
(:require
|
(:require
|
||||||
[views.protocols :refer :all]
|
[views.protocols :refer :all]
|
||||||
|
[views.honeysql.core :refer [hint-type]]
|
||||||
[views.honeysql.util :refer [query-tables]]
|
[views.honeysql.util :refer [query-tables]]
|
||||||
[honeysql.core :as hsql]
|
[honeysql.core :as hsql]
|
||||||
[clojure.set :refer [intersection]]
|
[clojure.set :refer [intersection]]
|
||||||
|
@ -18,7 +19,8 @@
|
||||||
data))
|
data))
|
||||||
(relevant? [_ namespace parameters hints]
|
(relevant? [_ namespace parameters hints]
|
||||||
(let [tables (query-tables (apply query-fn parameters))
|
(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)))))
|
(boolean (some #(not-empty (intersection (:hint %) tables)) nhints)))))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
|
|
Loading…
Reference in a new issue