I cannot find a way to insert an array of Postgres arrays with Clojure.
(sql/insert! db :things {:animals ["cow" "pig"]})
It didn’t work as I expected. Error message:
PSQLException Can't infer the SQL type to use for an instance of clojure.lang.PersistentVector. Use setObject() with an explicit Types value to specify the type to use. org.postgresql.jdbc2.AbstractJdbc2Statement.setObject (AbstractJdbc2Statement.java:1936)
Even the most direct SQL access I could find did not work:
(sql/execute! db "INSERT INTO things (animals) VALUES ('{\"cow\", \"pig\"}')")
I don’t know what is going on here:
ClassCastException java.lang.Character cannot be cast to java.lang.String clojure.java.jdbc/prepare-statement (jdbc.clj:419)
Is it really supposed to be possible? If not auxiliary functions, then raw SQL is somehow executed.
sql postgresql clojure jdbc
Erik strömberg
source share