Fork me on GitHub

Hi. I added postgres support via JDBC to babashka: I'm currently testing this with a Docker container locally. But I saw that next.jdbc itself tests with a library called "embedded postgres". How does this library work? Does it mock postgres, or does it really include it? Can it also be used to create something like sqlite, so beyond testing?


It's almost full-blown PostgreSQL just as an embedded server.


"The JAR file contains bundled version of Postgres. You can pass different Postgres version by implementing PgBinaryResolver."


(I don't think it has any persistence options, but I didn't dig very deep)


thanks. they explicitly mention "for testing" so that kind of hints at "don't use for anything serious" like a replacement for sqlite

Karol W贸jcik11:04:32

Hi. I'm looking for a way to automatically convert Clojure vector types to array of some type so that I can inject the data to pg database. I'm using next.jdbc and I cannot find the same parameters as in clojure.jdbc which would allow it. Any hints?


hi @karol.wojcik , in this documentation page there is a snippet about converting clojure map to json/jsonb data types


it might be very similar with what you are trying to achieve if I understood correctly


@karol.wojcik I have this function in my codebase:

(defn pg-array
  [conn v]
  (.createArrayOf  ^java.sql.Connection (:connection conn) "text" (into-array String v)))


@borkdude would be a wrong approach to extend the protocols and handle this?


@iagwanderson don't know. I found it a little weird that this function needs a connection, but maybe it needs to get some platform specific information via the connection to produce the array. Not sure if the protocols in next.jdbc support that


I looked into the code of the clj-postgresql and they have the conversion there through protocols. Would be like this following the examples in next.jdbc tips and tricks page:

(extend-protocol prepare/SettableParameter
  (set-parameter [v ^PreparedStatement s ^long i]
    (let [conn (.getConnection s)
          meta (.getParameterMetaData s)
          type-name (.getParameterTypeName meta i)]
      (if-let [elem-type (when type-name (second (re-find #"^_(.*)" type-name)))]
        (.setObject s i (.createArrayOf conn elem-type (to-array v)))
        (.setObject s i (vec->parameter v type-name))))))
@borkdude the conn is there yet 馃檪


do any one you use embedded postgres for testing btw? (


@karol.wojcik It sounds like you didn't find the answer in the next.jdbc docs? Here's the section in Getting Started that talks about working with additional data types


That links to the docs for extending how parameters are set (data going into the database) and how data is read from the DB.