From 21f6ff29d29225256e044e819142113e18aeb38d Mon Sep 17 00:00:00 2001 From: Dave Della Costa Date: Thu, 19 Jun 2014 12:08:35 +0900 Subject: [PATCH] moves computing dummy-view outside of view-check --- src/views/db/checks.clj | 5 ++--- test/views/db/checks_test.clj | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/views/db/checks.clj b/src/views/db/checks.clj index 70a6ecb..d9264d8 100644 --- a/src/views/db/checks.clj +++ b/src/views/db/checks.clj @@ -27,9 +27,8 @@ (map #(str "?" %) (range 0 (count (rest view-sig))))) (defn view-check - [action view-fn view-sig] - (let [view-map (apply view-fn (view-sig->dummy-args view-sig)) - {:keys [p q]} (swap-preds view-map)] + [action dummy-vm] + (let [{:keys [p q]} (swap-preds dummy-vm)] (-> q (update-in [:where] #(merge % (:where action))) (assoc :select (mapv second p))))) diff --git a/test/views/db/checks_test.clj b/test/views/db/checks_test.clj index e57a6a2..4095b6e 100644 --- a/test/views/db/checks_test.clj +++ b/test/views/db/checks_test.clj @@ -15,8 +15,9 @@ (is (= (:where q) (:where swapped))))) (deftest constructs-view-check - (let [update (hsql/build :update :foo :set {:d "d"} :where [:= :c "c"]) - check (hsql/build :select [:a :b] :from :foo :where [:and [:and true true] [:= :c "c"]]) - calcc (vc/view-check update view [:view 1 2])] + (let [dummy-vm (apply view (vc/view-sig->dummy-args [:view 1 2])) + update (hsql/build :update :foo :set {:d "d"} :where [:= :c "c"]) + check (hsql/build :select [:a :b] :from :foo :where [:and [:and true true] [:= :c "c"]]) + calcc (vc/view-check update dummy-vm)] ;;view )] (is (= (into #{} (:select check)) (into #{} (:select calcc)))) (is (= (:where check) (:where calcc)))))