fix #208 by turning unsupported into ""

This commit is contained in:
Sean Corfield 2022-07-31 15:29:14 -07:00
parent 7d5ee09e79
commit 9e21460cbb
2 changed files with 14 additions and 2 deletions

View file

@ -2,6 +2,9 @@
Only accretive/fixative changes will be made from now on.
* 1.2.next in progress
* Fix [#208](https://github.com/seancorfield/next-jdbc/issues/208) by treating unsupported exception as an empty string, just like the JDBC docs say should happen.
* 1.2.790 -- 2022-07-29
* Address [#207](https://github.com/seancorfield/next-jdbc/issues/207) by supporting "db-spec" hash maps containing `:datasource` or `:connection-uri` (this is otherwise undocumented and intended to aid migration from `clojure.java.jdbc`).
* Address [#199](https://github.com/seancorfield/next-jdbc/issues/199) by adding notes on UTC usage -- [@denismccarthykerry](https://github.com/denismccarthykerry).

View file

@ -33,12 +33,21 @@
(set! *warn-on-reflection* true)
(defn- get-table-name
"No, if it isn't supported, you're supposed to return
an empty string. That's what the JDBC docs say!"
[^ResultSetMetaData rsmeta ^Integer i]
(try
(.getTableName rsmeta i)
(catch java.sql.SQLFeatureNotSupportedException _
"")))
(defn get-column-names
"Given `ResultSetMetaData`, return a vector of column names, each qualified by
the table from which it came."
[^ResultSetMetaData rsmeta _]
(mapv (fn [^Integer i]
(if-let [q (not-empty (.getTableName rsmeta i))]
(if-let [q (not-empty (get-table-name rsmeta i))]
(keyword q (.getColumnLabel rsmeta i))
(keyword (.getColumnLabel rsmeta i))))
(range 1 (inc (if rsmeta (.getColumnCount rsmeta) 0)))))
@ -60,7 +69,7 @@
(assert qf ":qualifier-fn is required")
(assert lf ":label-fn is required")
(mapv (fn [^Integer i]
(if-let [q (some-> (.getTableName rsmeta i) (qf) (not-empty))]
(if-let [q (some-> (get-table-name rsmeta i) (qf) (not-empty))]
(keyword q (-> (.getColumnLabel rsmeta i) (lf)))
(keyword (-> (.getColumnLabel rsmeta i) (lf)))))
(range 1 (inc (if rsmeta (.getColumnCount rsmeta) 0))))))