ryoakg
3/30/2016 - 12:43 PM

sql-array.clj

(defn ^java.sql.Array sql-array
  "convert collection into java.sql.Array

sql-type-name: VARCHAR, CHAR, INTEGER, TIMESTAMP ..."
  [^java.sql.Connection conn ^String sql-type-name coll]
  (.createArrayOf conn
                  sql-type-name
                  (into-array String (mapv str coll))))

(defn sql-array->Vector
  "convert java.sql.Array into Vector"
  [^java.sql.Array a]
  (let [v (-> a .getArray vec)]
    (if (= v [nil])
      []
      v)))