omit for .cljs
Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
parent
1291b328d0
commit
35f4c674e9
2 changed files with 23 additions and 21 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
* 2.5.next in progress
|
* 2.5.next in progress
|
||||||
* Address [#520](https://github.com/seancorfield/honeysql/issues/520) by expanding how `:inline` works, to support a sequence of arguments.
|
* Address [#520](https://github.com/seancorfield/honeysql/issues/520) by expanding how `:inline` works, to support a sequence of arguments.
|
||||||
* Fix [#518](https://github.com/seancorfield/honeysql/issues/518) by moving temporal clause before alias.
|
* Fix [#518](https://github.com/seancorfield/honeysql/issues/518) by moving temporal clause before alias.
|
||||||
* Address [#495](https://github.com/seancorfield/honeysql/issues/495) by adding (experimental) `format&` and `formatv` macros -- purely for discussion: may be removed in a subsequent release!
|
* Address [#495](https://github.com/seancorfield/honeysql/issues/495) by adding (experimental) `format&` and `formatv` macros (`.clj` only!) -- purely for discussion: may be removed in a subsequent release!
|
||||||
* Implemented `CREATE INDEX` [#348](https://github.com/seancorfield/honeysql/issues/348) via PR [#517](https://github.com/seancorfield/honeysql/pull/517) [@dancek](https://github.com/dancek).
|
* Implemented `CREATE INDEX` [#348](https://github.com/seancorfield/honeysql/issues/348) via PR [#517](https://github.com/seancorfield/honeysql/pull/517) [@dancek](https://github.com/dancek).
|
||||||
|
|
||||||
* 2.5.1103 -- 2023-12-03
|
* 2.5.1103 -- 2023-12-03
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
it uppercase and replaces - with space). "
|
it uppercase and replaces - with space). "
|
||||||
(:refer-clojure :exclude [format])
|
(:refer-clojure :exclude [format])
|
||||||
(:require [clojure.string :as str]
|
(:require [clojure.string :as str]
|
||||||
[clojure.template]
|
#?(:clj [clojure.template])
|
||||||
[honey.sql.protocols :as p]))
|
[honey.sql.protocols :as p]))
|
||||||
|
|
||||||
;; default formatting for known clauses
|
;; default formatting for known clauses
|
||||||
|
|
@ -2101,32 +2101,34 @@
|
||||||
[dsl & params]
|
[dsl & params]
|
||||||
(format dsl {:params (zipmap (map (comp keyword str inc) (range)) params)}))
|
(format dsl {:params (zipmap (map (comp keyword str inc) (range)) params)}))
|
||||||
|
|
||||||
(defmacro format&
|
#?(:clj
|
||||||
"Experimental implementation of https://github.com/seancorfield/honeysql/issues/495
|
(defmacro format&
|
||||||
|
"Experimental implementation of https://github.com/seancorfield/honeysql/issues/495
|
||||||
|
|
||||||
Implicitly treats any locally bound symbol as a variable to be substituted
|
Implicitly treats any locally bound symbol as a variable to be substituted
|
||||||
in the symbolic SQL expression.
|
in the symbolic SQL expression.
|
||||||
|
|
||||||
(let [x 42 y 13]
|
(let [x 42 y 13]
|
||||||
(format& '{select * from table where (= x y)}))
|
(format& '{select * from table where (= x y)}))
|
||||||
|
|
||||||
=> SELECT * FROM table WHERE (42 = 13)"
|
=> SELECT * FROM table WHERE (42 = 13)"
|
||||||
[dsl & opts]
|
[dsl & opts]
|
||||||
(let [syms (vec (keys &env))]
|
(let [syms (vec (keys &env))]
|
||||||
`(honey.sql/format (clojure.template/apply-template '~syms ~dsl ~syms) ~@opts)))
|
`(honey.sql/format (clojure.template/apply-template '~syms ~dsl ~syms) ~@opts))))
|
||||||
|
|
||||||
(defmacro formatv
|
#?(:clj
|
||||||
"Experimental implementation of https://github.com/seancorfield/honeysql/issues/495
|
(defmacro formatv
|
||||||
|
"Experimental implementation of https://github.com/seancorfield/honeysql/issues/495
|
||||||
|
|
||||||
Treats the specified vector of symbols as variables to be substituted
|
Treats the specified vector of symbols as variables to be substituted
|
||||||
in the symbolic SQL expression.
|
in the symbolic SQL expression.
|
||||||
|
|
||||||
(let [x 42 y 13]
|
(let [x 42 y 13]
|
||||||
(formatv [x] '{select * from table where (= x y)}))
|
(formatv [x] '{select * from table where (= x y)}))
|
||||||
|
|
||||||
=> SELECT * FROM table WHERE (42 = y)"
|
=> SELECT * FROM table WHERE (42 = y)"
|
||||||
[syms sql & opts]
|
[syms sql & opts]
|
||||||
`(honey.sql/format (clojure.template/apply-template '~syms ~sql ~syms) ~@opts))
|
`(honey.sql/format (clojure.template/apply-template '~syms ~sql ~syms) ~@opts)))
|
||||||
|
|
||||||
(defn set-dialect!
|
(defn set-dialect!
|
||||||
"Set the default dialect for formatting.
|
"Set the default dialect for formatting.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue