Change (supposedly) opaque wrapper used by next.jdbc.types/as-* fns
This commit is contained in:
parent
63b3931134
commit
9cc0577214
3 changed files with 7 additions and 6 deletions
|
|
@ -4,6 +4,7 @@ Only accretive/fixative changes will be made from now on.
|
|||
|
||||
* 1.1.next in progress
|
||||
* Fix #140 by adding `"duckdb"` to `next.jdbc.connection/dbtypes`.
|
||||
* Change `next.jdbc.types/as-*` functions to use a thunk instead of a vector to convey metadata, so that wrapped values do not get unpacked by HoneySQL.
|
||||
|
||||
## Stable Builds
|
||||
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@
|
|||
(str/lower-case)
|
||||
(str/replace "_" "-"))))]
|
||||
`(defn ~as-n
|
||||
~(str "Wrap a Clojure value in a vector with metadata to implement `set-parameter`
|
||||
~(str "Wrap a Clojure value in a thunk with metadata to implement `set-parameter`
|
||||
so that `.setObject()` is called with the `java.sql.Types/" n "` SQL type.")
|
||||
[~'obj]
|
||||
(with-meta [~'obj]
|
||||
(with-meta (constantly ~'obj)
|
||||
{'next.jdbc.prepare/set-parameter
|
||||
(fn [[v#] ^PreparedStatement s# ^long i#]
|
||||
(.setObject s# i# v# ~(symbol "java.sql.Types" n)))})))))))
|
||||
(fn [vf# ^PreparedStatement s# ^long i#]
|
||||
(.setObject s# i# (vf#) ~(symbol "java.sql.Types" n)))})))))))
|
||||
|
||||
(all-types)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
(ns next.jdbc.types-test
|
||||
"Some tests for the type-assist functions."
|
||||
(:require [clojure.test :refer [deftest is testing]]
|
||||
(:require [clojure.test :refer [deftest is]]
|
||||
[next.jdbc.types :refer [as-varchar]]))
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
||||
(deftest as-varchar-test
|
||||
(let [v (as-varchar "Hello")]
|
||||
(is (= ["Hello"] v))
|
||||
(is (= "Hello" (v)))
|
||||
(is (contains? (meta v) 'next.jdbc.prepare/set-parameter))
|
||||
(is (fn? (get (meta v) 'next.jdbc.prepare/set-parameter)))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue