babashka / babashka-sql-pods

Babashka pods for SQL databases
Eclipse Public License 1.0
85 stars 17 forks source link

Serialize postgres arrays to vectors #7

Closed borkdude closed 3 years ago

borkdude commented 4 years ago

See https://cljdoc.org/d/seancorfield/next.jdbc/1.0.445/doc/getting-started/tips-tricks#working-with-arrays

Workarounds:

aviflax commented 3 years ago

As discussed in Clojurians, I’ve run into the related problem of inserting into an array column; I get clojure.lang.ExceptionInfo: No reader function for tag object as per these logs produced via this code.

So it’d be great if the pod would also support inserting vectors (or arrays, or seqables, or whatever) into a PostgreSQL array column.

Thanks!

borkdude commented 3 years ago

From Slack:

4:46 PM borkdude @avi I think the insert problem will solve itself if we switch the pod format to transit which can cope with serializing arrays 4:46 PM avi:nerd_face: Makes sense, sounds promising. I’d love to help test if/when the time comes! 4:46 PM borkdude For retrieving array we still need to do something, as described here: https://github.com/seancorfield/next-jdbc/blob/develop/doc/tips-and-tricks.md#working-with-arrays

borkdude commented 3 years ago

Switched to transit now on master. I'm a bit surprised that transit doesn't support serializing arrays out of the box, this is what I expected.

user=> (write-transit [1 2 3])
"[1,2,3]"
user=> (write-transit (into-array [1 2 3]))
Execution error (NullPointerException) at com.cognitect.transit.impl.AbstractEmitter/marshalTop (AbstractEmitter.java:203).
borkdude commented 3 years ago

@aviflax Now supported in 0.0.3.

Behavior:

aviflax commented 3 years ago

Excellent! Thank you!