Fork me on GitHub
#sql
<
2020-04-13
>
dcj20:04:15

WRT next.jdbc: is there a way to attach some data to a datasource that would be http://accessible.re/retrievable within the implementation of the read-column-by-index method of the result-set/ReadableColumn protocol? Perhaps via the result-set-metadata that is passed in... What I am really trying to do is to compare the ColumnTypeName to a list that I obtain by querying the pg_type table the system catalog, (specifically select typname from pg_type where typtype='e'; I want to make that query soon after creating my long-lived connection pool, and put the resulting list/set "somewhere" that can be retrieved within a read-column-by-index method implementation. My overall goal is to automatically coerce between Clojure keywords and Postgres enums, as https://www.bevuta.com/en/blog/using-postgresql-enums-in-clojure/. That implementation requires a set of defined ENUM types, which they hard-code (which they clearly mentioned as a limitation, and which I am attempting to improve upon)

seancorfield21:04:43

@dcj You should be able to do this via one of the *-adapter builders, since you can pass an arbitrary "column reader" function in, which is invoked with the (current) ResultSet, ResultSetMetadata (returned by the builder), and the column index.

seancorfield21:04:22

(you can't attach anything to the javax.sql.DataSource or java.sql.Connection because they are plain Java objects)

seancorfield21:04:50

Your column reader could close over the specific column metadata you had queried earlier.

dcj21:04:44

@seancorfield Cool, thank you! I will explore that direction...