From 66914e32be56663950b08996ac076e11b1f56e61 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Tue, 14 May 2013 18:24:14 +1000 Subject: Fix precondition on rename The precondition was too strong. Loosen it just enough to make the function useful in all the ways it should be without allowing bad cases through. --- src/clojure_sql/core.clj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/clojure_sql/core.clj b/src/clojure_sql/core.clj index 6cdb115..c829331 100644 --- a/src/clojure_sql/core.clj +++ b/src/clojure_sql/core.clj @@ -208,8 +208,10 @@ (defn rename [query field-renames] {:pre [(map? field-renames) + ;; the intersection of the new aliases with the old aliases NOT renamed by this operation (empty? (set/intersection (set (vals field-renames)) - (set (vals (:fields query)))))]} + (set/difference (set (vals (:fields query))) + (set (keys field-renames)))))]} (let [fields (:fields query) alias-lookup (u/flip-map (:fields query)) original-name (fn [field] @@ -337,7 +339,8 @@ deref) (-> (table :users) (project [:id :name]) - (rename {:id :name}) + (rename {:id :name + :name :id}) deref) (-> (table :anotherStack) -- cgit v1.2.3