sql

All things SQL and JDBC...
2020-04-13T20:29:15.247Z

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)

seancorfield 2020-04-13T21:20:43.248500Z

@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.

seancorfield 2020-04-13T21:21:22.249200Z

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

seancorfield 2020-04-13T21:22:50.250100Z

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

2020-04-13T21:24:44.250600Z

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