add formatf experiment #495
This commit is contained in:
parent
e7972ac1b4
commit
e679e93362
2 changed files with 10 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
* 2.4.next in progress
|
* 2.4.next in progress
|
||||||
|
* Address [#495](https://github.com/seancorfield/honeysql/issues/495) by adding (experimental) `formatf` function. Documentation TBD.
|
||||||
* Fix [#494](https://github.com/seancorfield/honeysql/issues/494) by supporting expressions in `:on-conflict` instead of just entities.
|
* Fix [#494](https://github.com/seancorfield/honeysql/issues/494) by supporting expressions in `:on-conflict` instead of just entities.
|
||||||
* Address [#493](https://github.com/seancorfield/honeysql/issues/493) by clarifying use of `:values` in CTEs (using `:with`).
|
* Address [#493](https://github.com/seancorfield/honeysql/issues/493) by clarifying use of `:values` in CTEs (using `:with`).
|
||||||
* Address [#489](https://github.com/seancorfield/honeysql/issues/489) by adding more examples around `:update`.
|
* Address [#489](https://github.com/seancorfield/honeysql/issues/489) by adding more examples around `:update`.
|
||||||
|
|
|
||||||
|
|
@ -1810,6 +1810,13 @@
|
||||||
(mapv #(unwrap % opts) (formatter data opts))))))
|
(mapv #(unwrap % opts) (formatter data opts))))))
|
||||||
([data k v & {:as opts}] (format data (assoc opts k v))))
|
([data k v & {:as opts}] (format data (assoc opts k v))))
|
||||||
|
|
||||||
|
(defn formatf
|
||||||
|
"Experimental implementation of https://github.com/seancorfield/honeysql/issues/495
|
||||||
|
|
||||||
|
Currently, does not support options."
|
||||||
|
[dsl & params]
|
||||||
|
(format dsl {:params (zipmap (map (comp keyword str inc) (range)) params)}))
|
||||||
|
|
||||||
(defn set-dialect!
|
(defn set-dialect!
|
||||||
"Set the default dialect for formatting.
|
"Set the default dialect for formatting.
|
||||||
|
|
||||||
|
|
@ -2074,4 +2081,6 @@
|
||||||
(sql/register-fn! :foo foo-formatter)
|
(sql/register-fn! :foo foo-formatter)
|
||||||
|
|
||||||
(sql/format {:select [:*], :from [:table], :where [:foo [:+ :a 1]]})
|
(sql/format {:select [:*], :from [:table], :where [:foo [:+ :a 1]]})
|
||||||
|
(sql/formatf '{select * from table where (foo (+ a 1))})
|
||||||
|
(sql/formatf '{select * from table where (foo (+ a ?1))} 42)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue