diff options
author | Carlo Zancanaro <carlo@clearboxsystems.com.au> | 2013-05-14 18:24:14 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@clearboxsystems.com.au> | 2013-05-14 18:24:14 +1000 |
commit | 66914e32be56663950b08996ac076e11b1f56e61 (patch) | |
tree | 0e41fb6d96aebd3f7e096f9c94d8247a2f75f1d9 /src | |
parent | 1d7cc24207467f09940525e7e6716546504909d9 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/clojure_sql/core.clj | 7 |
1 files 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) |