summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clojure_sql/core.clj7
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)