diff --git a/CHANGELOG.md b/CHANGELOG.md index 89f9bcb..dc3666d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changes * 2.1.next in progress + * Fix #375 for `:nest` statement. * Update test dependencies. * Update `build-clj` to v0.6.1. diff --git a/doc/special-syntax.md b/doc/special-syntax.md index 231690e..0bfe68f 100644 --- a/doc/special-syntax.md +++ b/doc/special-syntax.md @@ -201,6 +201,12 @@ level of parentheses around it: `:nest` is also supported as a SQL clause for the same reason. +```clojure +;; BigQuery requires UNION clauses be parenthesized: +(sql/format {:union-all [{:nest {:select :*}} {:nest {:select :*}}]}) +;;=> ["(SELECT *) UNION ALL (SELECT *)"] +``` + ## not Accepts a single expression and formats it with `NOT` diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 14cfd1a..64cc91d 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -875,8 +875,8 @@ :refresh-materialized-view (fn [_ x] (format-create :refresh :materialized-view x nil)) :raw (fn [_ x] (raw-render x)) :nest (fn [_ x] - (let [[sql & params] (format-expr x)] - (into [(str "(" sql ")")] params))) + (let [[sql & params] (format-dsl x {:nested true})] + (into [sql] params))) :with #'format-with :with-recursive #'format-with :intersect #'format-on-set-op