From 31cbecf41102ed0ba4a48f2dd21044f8822f4e0d Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sun, 31 Mar 2019 17:30:10 -0700 Subject: [PATCH] Improve function naming in prepare ns --- src/next/jdbc/prepare.clj | 6 +++--- src/next/jdbc/result_set.clj | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/next/jdbc/prepare.clj b/src/next/jdbc/prepare.clj index 013fcae..c5f24df 100644 --- a/src/next/jdbc/prepare.clj +++ b/src/next/jdbc/prepare.clj @@ -44,7 +44,7 @@ [return-keys] (into-array String return-keys)) -(defn pre-prepare* +(defn ->factory "Given a some options, return a statement factory -- a function that will accept a connection and a SQL string and parameters, and return a PreparedStatement representing that." @@ -106,7 +106,7 @@ (fn [^Connection con ^String sql] (.setQueryTimeout ^PreparedStatement (f con sql) timeout))))) -(defn prepare-fn* +(defn create "Given a connection, a SQL statement, its parameters, and a statement factory, return a PreparedStatement representing that." ^java.sql.PreparedStatement @@ -117,5 +117,5 @@ java.sql.Connection (prepare [this sql-params opts] (let [[sql & params] sql-params - factory (pre-prepare* opts)] + factory (->factory opts)] (set-parameters (factory this sql) params)))) diff --git a/src/next/jdbc/result_set.clj b/src/next/jdbc/result_set.clj index 081eced..7e204de 100644 --- a/src/next/jdbc/result_set.clj +++ b/src/next/jdbc/result_set.clj @@ -96,24 +96,24 @@ (extend-protocol p/Executable java.sql.Connection (-execute [this sql-params opts] - (let [factory (prepare/pre-prepare* opts)] + (let [factory (prepare/->factory opts)] (reify clojure.lang.IReduceInit (reduce [_ f init] - (with-open [stmt (prepare/prepare-fn* this - (first sql-params) - (rest sql-params) - factory)] + (with-open [stmt (prepare/create this + (first sql-params) + (rest sql-params) + factory)] (reduce-stmt stmt f init opts)))))) javax.sql.DataSource (-execute [this sql-params opts] - (let [factory (prepare/pre-prepare* opts)] + (let [factory (prepare/->factory opts)] (reify clojure.lang.IReduceInit (reduce [_ f init] (with-open [con (p/get-connection this opts)] - (with-open [stmt (prepare/prepare-fn* con - (first sql-params) - (rest sql-params) - factory)] + (with-open [stmt (prepare/create con + (first sql-params) + (rest sql-params) + factory)] (reduce-stmt stmt f init opts))))))) java.sql.PreparedStatement (-execute [this _ opts] @@ -129,7 +129,7 @@ (declare navize-row) -(defn- row-into-map +(defn datafiable-row [connectable opts] (fn [row] (into (with-meta {} {`core-p/datafy (navize-row connectable opts)}) row))) @@ -138,13 +138,13 @@ "" [connectable sql-params opts] (into [] - (map (or (:row-fn opts) (row-into-map connectable opts))) + (map (or (:row-fn opts) (datafiable-row connectable opts))) (p/-execute connectable sql-params opts))) (defn execute-one! "" [connectable sql-params opts] - (let [row-fn (or (:row-fn opts) (row-into-map connectable opts))] + (let [row-fn (or (:row-fn opts) (datafiable-row connectable opts))] (reduce (fn [_ row] (reduced (row-fn row))) nil