Next.jdbc 1.0.0 Beta 1

Over the weekend, I released 1.0.0 Beta 1. The API is now stable and the library will have only accretive/fixative changes from now on.

The library will continue to live at and its group/artifact ID will continue to be seancorfield/next.jdbc – so it will accept Pull Requests (the contributing page has been updated!).

There is one breaking change from Alpha 13: reducible! was renamed to plan – this was the gating issue for moving out of Alpha status, along with the decision about Contrib, so that no more breaking changes will need to be made.

Read Getting Started to take it for a test drive!

Thank you for all the feedback, here and elsewhere!


Thank you for taking the time to design and implement an improved API, and also for the awesome documentation!

1 Like

I want to replicate something like {:row-fn #(str/replace % #"_" "-")} with next.jdbc, it seems like I should write my own version of next.jdbc.result-set/get-column-names, use that to make my own version of as-maps, and finally pass that in as the :builder-fn, correct?

(defn get-kebab-column-names
  [^ResultSetMetaData rsmeta opts]
  (mapv (fn [^Integer i] (keyword
                           (not-empty (.getTableName rsmeta i))
                           #"_" "-")
                           (.getColumnLabel rsmeta i)
                           #"_" "-")))
        (range 1 (inc (.getColumnCount rsmeta)))))

(defn as-kebab-maps
  [^ResultSet rs opts]
  (let [rsmeta (.getMetaData rs)
        cols  (get-kebab-column-names rsmeta opts)]
    (result-set/->MapResultSetBuilder rs rsmeta cols)))

:row-fn operates on values and cannot affect the column names. Are you thinking of :identifiers?

Your code will blow up (NPE) on columns that have no associated table name – you’ll want to follow the pattern in get-lower-column-names to avoid that.

Otherwise, yes, this is the expected approach for creating your own naming convention for builders. – no promises on whether that will be added, but it would reduce the boilerplate for people wanting to write custom identifier naming strategies.

Yep, thanks, I did immediately run into the nil table name issue, good catch :slight_smile:

1.0.0-rc1 is available with new builder functions that accept a transformation function:

(defn as-kebab-maps [rs opts] 
  (let [kebab #(str/replace % #"_" "-")]
    (result-set/as-modified-maps rs (assoc opts :qualifier-fn kebab :label-fn kebab))))

As with :column-fn/:table-fn, you can specify that column labels and table qualifiers are transformed differently.

1 Like