Back
row! (clj)
(source)protocol
(row! _ row)
Called once per row to finalize each row once it is complete.
Examples
next-jdbc
What's left to be tested:
* ReadableColumn protocol extension point"
(:require [clojure.core.protocols :as core-p]
[clojure.datafy :as d]
[clojure.string :as str]
[clojure.test :refer [deftest is testing use-fixtures]]
[next.jdbc.protocols :as p]
[next.jdbc.result-set :as rs]
[next.jdbc.specs :as specs]
[next.jdbc.test-fixtures :refer [with-test-db ds column
default-options
derby? mssql? mysql? postgres?]])
(:import (java.sql ResultSet ResultSetMetaData)))
(defn fruit-builder [^ResultSet rs ^ResultSetMetaData rsmeta]
(reify
rs/RowBuilder
(->row [_] (->Fruit (.getObject rs "id")
(.getObject rs "name")
(.getObject rs "appearance")
(.getObject rs "cost")
(.getObject rs "grade")))
(column-count [_] 0) ; no need to iterate over columns
(with-column [_ row i] row)
(with-column-value [_ row col v] row)
(row! [_ row] row)
rs/ResultSetBuilder
(->rs [_] (transient []))
(with-row [_ rs row] (conj! rs row))
(rs! [_ rs] (persistent! rs))
clojure.lang.ILookup ; only supports :cols and :rsmeta
(valAt [this k] (get this k nil))
(valAt [this k not-found]
(case k
:cols [:id :name :appearance :cost :grade]
:rsmeta rsmeta
not-found))))