fixes #287 by merging instead of assoc'ing

Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
Sean Corfield 2024-11-15 18:19:32 -08:00
parent 03117d1160
commit a75468105f
No known key found for this signature in database
2 changed files with 9 additions and 6 deletions

View file

@ -2,6 +2,9 @@
Only accretive/fixative changes will be made from now on.
* 1.3.next in progress
* Fix [#287](https://github.com/seancorfield/next-jdbc/issues/287) by merging user-supplied options over `:return-keys true`.
* 1.3.955 -- 2024-10-06
* Address [#285](https://github.com/seancorfield/next-jdbc/issues/285) by setting the default Clojure version to the earliest supported (1.10.3) to give a better hint to users.
* Update PostgreSQL **Tips & Tricks** example code to fix possible NPE. PR [#284](https://github.com/seancorfield/next-jdbc/pull/284) from [@ExNexu](https://github.com/ExNexu).

View file

@ -952,14 +952,14 @@
(reify
clojure.lang.IReduceInit
(reduce [_ f init]
(reduce-stmt this f init (assoc opts :return-keys true)))
(reduce-stmt this f init (merge {:return-keys true} opts)))
r/CollFold
(coll-fold [_ n combinef reducef]
(fold-stmt this n combinef reducef (.getConnection this)
(assoc opts :return-keys true)))
(merge {:return-keys true} opts)))
(toString [_] "`IReduceInit` from `plan` -- missing reduction?")))
(-execute-one [this _ opts]
(if-let [rs (stmt->result-set this (assoc opts :return-keys true))]
(if-let [rs (stmt->result-set this (merge {:return-keys true} opts))]
(let [builder-fn (get opts :builder-fn as-maps)
builder (builder-fn rs opts)]
(when (.next rs)
@ -970,10 +970,10 @@
(if (:multi-rs opts)
(loop [go (.execute this) acc []]
(if-let [rs (stmt->result-set-update-count
(.getConnection this) this go (assoc opts :return-keys true))]
(.getConnection this) this go (merge {:return-keys true} opts))]
(recur (.getMoreResults this) (conj acc rs))
acc))
(if-let [rs (stmt->result-set this (assoc opts :return-keys true))]
(if-let [rs (stmt->result-set this (merge {:return-keys true} opts))]
(datafiable-result-set rs (.getConnection this) opts)
[{:next.jdbc/update-count (.getUpdateCount this)}])))
@ -1006,7 +1006,7 @@
(if (:multi-rs opts)
(loop [go (.execute this (first sql-params)) acc []]
(if-let [rs (stmt->result-set-update-count
(.getConnection this) this go (assoc opts :return-keys true))]
(.getConnection this) this go (merge {:return-keys true} opts))]
(recur (.getMoreResults this) (conj acc rs))
acc))
(if-let [rs (stmt-sql->result-set this (first sql-params))]