Merge pull request #111 from stuarth/master

allow joins without a pred
This commit is contained in:
Michael Blume 2016-03-30 23:10:18 -07:00
commit 43df955a86
2 changed files with 12 additions and 4 deletions

View file

@ -414,10 +414,10 @@
(str "WHERE " (format-predicate* pred)))
(defn format-join [type table pred]
(str (when type
(str (string/upper-case (name type)) " "))
"JOIN " (to-sql table)
" ON " (format-predicate* pred)))
(cond-> (str (when type
(str (string/upper-case (name type)) " "))
"JOIN " (to-sql table))
pred (str " ON " (format-predicate* pred))))
(defmethod format-clause :join [[_ join-groups] _]
(space-join (map #(apply format-join :inner %)

View file

@ -165,3 +165,11 @@
(-> (select (sql/call :min "time"))
(from "table")
sql/format))))
(deftest join-test
(testing "nil join"
(is (= ["SELECT * FROM foo INNER JOIN x ON foo.id = x.id INNER JOIN y"]
(-> (select :*)
(from :foo)
(join :x [:= :foo.id :x.id] :y nil)
sql/format)))))