Skip to content

Commit

Permalink
a simplification to prepare for #542
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Corfield <[email protected]>
  • Loading branch information
seancorfield committed Sep 22, 2024
1 parent dd9547b commit 150fcda
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/honey/sql.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -822,10 +822,16 @@
(into [(str (format-entity (first x)) " " sql)] params))
[(format-entity x)]))

(defn- format-with [k xs as-fn]
(defn- format-with [k xs]
;; TODO: a sequence of pairs -- X AS expr -- where X is either [entity expr]
;; or just entity, as far as I can tell...
(let [[sqls params]
(let [as-fn
(fn [[_ _ materialization]]
(condp = materialization
:materialized "AS MATERIALIZED"
:not-materialized "AS NOT MATERIALIZED"
"AS"))
[sqls params]
(reduce-sql
(map
(fn [[x expr :as with]]
Expand Down Expand Up @@ -1487,15 +1493,8 @@
:nest (fn [_ x]
(let [[sql & params] (format-dsl x {:nested true})]
(into [sql] params)))
:with (let [as-fn
(fn [[_ _ materialization]]
(condp = materialization
:materialized "AS MATERIALIZED"
:not-materialized "AS NOT MATERIALIZED"
"AS"))]
(fn [k xs] (format-with k xs as-fn)))
:with-recursive (let [as-fn (constantly "AS")]
(fn [k xs] (format-with k xs as-fn)))
:with #'format-with
:with-recursive #'format-with
:intersect #'format-on-set-op
:union #'format-on-set-op
:union-all #'format-on-set-op
Expand Down

0 comments on commit 150fcda

Please sign in to comment.