1

I have a h2 database and am trying to create a view with a column that uses array_agg on some text columns:

create view full as 
select av.*, at.tag from anno_v av 
left join
(select id, array_agg(tags) as tag from anno_t group by id) at 
on at.id = av.id

I'm using clojure's java.jdbc 0.7.0 library to query the result set, and am trying to convert the array type to a clojure vector using the :row-fn option (per this example) when I do

(jdbc/query db ["SELECT * FROM full"] {:row-fn my-parser})

where

(defn my-parser [row] (assoc row :tag (vec (.getArray (:tag row)))))

I get the error message IllegalArgumentException No matching field found: getArray for class org.h2.jdbc.JdbcClob clojure.lang.Reflector.getInstanceField (Reflector.java:271)

The same query works on my postgres implementation of the view (same sql syntax to create the view, same clojure code). Does anyone know why the array column is being converted to a clob and how I can get it back to an array? I saw this comment saying the jdbc array type is not supported for java dbs, but wasn't sure if that applied to my case.

thanks!

1
  • ask on #sql channel on Slack clojurians, as seancorfield who is the maintainer of jdbc is there solving issues daily. ...and please post back here for completeness.. Dec 12, 2018 at 15:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.