This commit is contained in:
Sean Corfield 2022-09-23 10:59:41 -07:00
parent 0c6591054f
commit 961b880e08
3 changed files with 20 additions and 2 deletions

View file

@ -3,6 +3,7 @@
Only accretive/fixative changes will be made from now on. Only accretive/fixative changes will be made from now on.
* 1.3.next in progress * 1.3.next in progress
* Fix [#227](https://github.com/seancorfield/next-jdbc/issues/227) by correcting how [#221](https://github.com/seancorfield/next-jdbc/issues/221) was implemented.
* Address [#224](https://github.com/seancorfield/next-jdbc/issues/224) by attempting to clarify how to use the snake/kebab options and builders. * Address [#224](https://github.com/seancorfield/next-jdbc/issues/224) by attempting to clarify how to use the snake/kebab options and builders.
* 1.3.828 -- 2022-09-11 * 1.3.828 -- 2022-09-11

View file

@ -486,7 +486,9 @@
(metadata-preserving) operations on it." (metadata-preserving) operations on it."
[^ResultSet rs opts] [^ResultSet rs opts]
(let [builder (delay ((get opts :builder-fn as-maps) rs opts)) (let [builder (delay ((get opts :builder-fn as-maps) rs opts))
name-fn (get opts :column-fn name)] name-fn (if (contains? opts :column-fn)
(comp (get opts :column-fn) name)
name)]
(reify (reify
MapifiedResultSet MapifiedResultSet

View file

@ -6,7 +6,8 @@
[next.jdbc.plan :as plan] [next.jdbc.plan :as plan]
[next.jdbc.specs :as specs] [next.jdbc.specs :as specs]
[next.jdbc.test-fixtures [next.jdbc.test-fixtures
:refer [with-test-db ds]])) :refer [with-test-db ds]]
[clojure.string :as str]))
(set! *warn-on-reflection* true) (set! *warn-on-reflection* true)
@ -55,3 +56,17 @@
(is (= {1 "Apple", 2 "Banana", 3 "Peach", 4 "Orange"} (is (= {1 "Apple", 2 "Banana", 3 "Peach", 4 "Orange"}
(plan/select! (ds) (juxt :id :name) ["select * from fruit order by id"] (plan/select! (ds) (juxt :id :name) ["select * from fruit order by id"]
{:into {}})))) {:into {}}))))
(deftest select-issue-227
(is (= ["Apple"]
(plan/select! (ds) :name ["select * from fruit where id = ?" 1]
{:column-fn #(str/replace % "-" "_")})))
(is (= ["Apple"]
(plan/select! (ds) :foo/name ["select * from fruit where id = ?" 1]
{:column-fn #(str/replace % "-" "_")})))
(is (= ["Apple"]
(plan/select! (ds) #(get % "name") ["select * from fruit where id = ?" 1]
{:column-fn #(str/replace % "-" "_")})))
(is (= [["Apple"]]
(plan/select! (ds) (juxt :name) ["select * from fruit where id = ?" 1]
{:column-fn #(str/replace % "-" "_")}))))