diff options
Diffstat (limited to 'src/clojure_sql/compiler.clj')
-rw-r--r-- | src/clojure_sql/compiler.clj | 15 |
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)) |