summaryrefslogtreecommitdiff
path: root/src/clojure_sql/compiler.clj
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@clearboxsystems.com.au>2013-06-16 01:26:31 +1000
committerCarlo Zancanaro <carlo@clearboxsystems.com.au>2013-06-16 01:26:31 +1000
commit4ab5ae273750c0d52ec72f103fe9165b52d2abb6 (patch)
treee44bea2b9bdbc117dc7530334b756e4b1574597b /src/clojure_sql/compiler.clj
parent233e9bd34462d3b02a7a3af148994f9a013b34ab (diff)
Fix up some more join stuff, and a bit of sorting stuff.
Diffstat (limited to 'src/clojure_sql/compiler.clj')
-rw-r--r--src/clojure_sql/compiler.clj15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/clojure_sql/compiler.clj b/src/clojure_sql/compiler.clj
index 0022256..6f940c0 100644
--- a/src/clojure_sql/compiler.clj
+++ b/src/clojure_sql/compiler.clj
@@ -118,6 +118,13 @@
((p-lift string/join ", ")))
(return "*")))
+(def ^:private join-type-names
+ {:inner "INNER"
+ :left "LEFT OUTER"
+ :right "RIGHT OUTER"
+ :outer "FULL OUTER"
+ :cross "CROSS"})
+
(defmulti compile-tables (fn [db _ _] db))
(defmethod compile-tables :default [db join tables-map]
(if (vector? join)
@@ -128,10 +135,12 @@
(let [{:keys [left right type on]} join]
($str (return "(")
(compile-tables db left tables-map)
- (return (str " " (name type) " JOIN "))
+ (return (str " " (get join-type-names type (name type)) " JOIN "))
(compile-tables db right tables-map)
- (return " ON ")
- (compile-expression db on)
+ (if on
+ ($str (return " ON ")
+ (compile-expression db on))
+ (return ""))
(return ")")))))
(defmulti compile-where (fn [db _] db))