Back
clob-column-reader (clj)
(source)function
(clob-column-reader rs _ i)
An example column-reader that still uses `.getObject` but expands CLOB
columns into strings.
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)))
(deftest clob-reading
(when-not (or (mssql?) (mysql?) (postgres?)) ; no clob in these
(with-open [con (p/get-connection (ds) {})]
(try
(p/-execute-one con ["DROP TABLE CLOBBER"] {})
(catch Exception _))
(p/-execute-one con [(str "
CREATE TABLE CLOBBER (
ID INTEGER,
STUFF CLOB
)")]
{})
(p/-execute-one con
[(str "insert into clobber (id, stuff)"
"values (?,?), (?,?)")
1 "This is some long string"
2 "This is another long string"]
{})
(is (= "This is some long string"
(-> (p/-execute-all con
["select * from clobber where id = ?" 1]
{:builder-fn (rs/as-maps-adapter
rs/as-unqualified-lower-maps
rs/clob-column-reader)})
(first)
:stuff))))))