diff --git a/src/views/honeysql/core.clj b/src/views/honeysql/core.clj index 190fc4a..3e9e4f6 100644 --- a/src/views/honeysql/core.clj +++ b/src/views/honeysql/core.clj @@ -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))) diff --git a/src/views/honeysql/view.clj b/src/views/honeysql/view.clj index 64835d5..ce88602 100644 --- a/src/views/honeysql/view.clj +++ b/src/views/honeysql/view.clj @@ -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