allow joins without a pred
This commit is contained in:
parent
a25ce4db5d
commit
80e9d2ec44
2 changed files with 12 additions and 4 deletions
|
|
@ -414,10 +414,10 @@
|
||||||
(str "WHERE " (format-predicate* pred)))
|
(str "WHERE " (format-predicate* pred)))
|
||||||
|
|
||||||
(defn format-join [type table pred]
|
(defn format-join [type table pred]
|
||||||
(str (when type
|
(cond-> (str (when type
|
||||||
(str (string/upper-case (name type)) " "))
|
(str (string/upper-case (name type)) " "))
|
||||||
"JOIN " (to-sql table)
|
"JOIN " (to-sql table))
|
||||||
" ON " (format-predicate* pred)))
|
pred (str " ON " (format-predicate* pred))))
|
||||||
|
|
||||||
(defmethod format-clause :join [[_ join-groups] _]
|
(defmethod format-clause :join [[_ join-groups] _]
|
||||||
(space-join (map #(apply format-join :inner %)
|
(space-join (map #(apply format-join :inner %)
|
||||||
|
|
|
||||||
|
|
@ -165,3 +165,11 @@
|
||||||
(-> (select (sql/call :min "time"))
|
(-> (select (sql/call :min "time"))
|
||||||
(from "table")
|
(from "table")
|
||||||
sql/format))))
|
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)))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue