From 5b140282fb76ee86ea6afe598d2d16ec423e07db Mon Sep 17 00:00:00 2001 From: Oleksandr Yakushev Date: Tue, 8 Oct 2024 18:58:45 +0300 Subject: [PATCH] [jdbc.read] Properly pre-compute column fetching thunk --- src/toucan2/jdbc/read.clj | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/toucan2/jdbc/read.clj b/src/toucan2/jdbc/read.clj index 4e09e7e..7479402 100644 --- a/src/toucan2/jdbc/read.clj +++ b/src/toucan2/jdbc/read.clj @@ -130,11 +130,10 @@ (defn- make-column-thunk [conn model ^ResultSet rset i] (log/tracef "Building thunk to read column %s" i) - (fn column-thunk [] - (let [rsmeta (.getMetaData rset) - thunk (read-column-thunk conn model rset rsmeta i) - v (thunk)] - (next.jdbc.rs/read-column-by-index v rsmeta i)))) + (let [rsmeta (.getMetaData rset) + thunk (read-column-thunk conn model rset rsmeta i)] + (fn column-thunk [] + (next.jdbc.rs/read-column-by-index (thunk) rsmeta i)))) (defn ^:no-doc make-i->thunk "Given a connection `conn`, a `model` and a result set `rset`, return a function which given a column number `i` returns