summaryrefslogtreecommitdiff
path: root/src/clojure_sql/compiler.clj
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@clearboxsystems.com.au>2013-11-25 01:13:11 +1100
committerCarlo Zancanaro <carlo@clearboxsystems.com.au>2013-11-25 01:13:11 +1100
commit2746c6b08b878190ee7c54a7414bf444c660ff1e (patch)
tree5484cb43cb1da1c8a4ccd4207ac5a6cdf311002d /src/clojure_sql/compiler.clj
parenta2aabf7b89da6313c3b47e603a2668d55ad946b7 (diff)
Add a 'distinct' operator - still a bug to fix on renaming
Diffstat (limited to 'src/clojure_sql/compiler.clj')
-rw-r--r--src/clojure_sql/compiler.clj4
1 files changed, 3 insertions, 1 deletions
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 ")