From 2746c6b08b878190ee7c54a7414bf444c660ff1e Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 25 Nov 2013 01:13:11 +1100 Subject: Add a 'distinct' operator - still a bug to fix on renaming --- src/clojure_sql/compiler.clj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/clojure_sql/compiler.clj') diff --git a/src/clojure_sql/compiler.clj b/src/clojure_sql/compiler.clj index 50c14af..828da64 100644 --- a/src/clojure_sql/compiler.clj +++ b/src/clojure_sql/compiler.clj @@ -225,7 +225,7 @@ (def ^:private set-operations {:union "UNION", :intersect "INTERSECT"}) (defmulti compile-query (fn [db _] db) :default :postgres) -(defmethod compile-query :postgres [db {:keys [tables fields joins where sort group having take drop set-operation queries]}] +(defmethod compile-query :postgres [db {:keys [tables fields joins where sort group having take drop distinct set-operation queries]}] (or (if set-operation (let [op-str (str ") " (get set-operations set-operation) " (")] (->> queries @@ -234,6 +234,8 @@ ((p-lift string/join op-str)) $add-parentheses))) ($str (return "SELECT ") + (return (if distinct + "DISTINCT ")) (compile-fields db fields) (if tables ($str (return " FROM ") -- cgit v1.2.3