Fork me on GitHub
#babashka
<
2021-02-24
>
borkdude11:02:02

This could be useful in case you want to port a babashka script to deps.edn and want to compile it with GraalVM, perhaps.

anthony-galea13:02:44

I'm trying to write a babashka script that involves reading data from postgres. Some of this data is in a json column. When my query runs I see: Cannot read EDN: ... #object[org.postgresql.util.PGobject .... :cause "No reader function for tag object" I've noticed that sql-pods uses the next.jdbc library so I tried following the advice here: https://cljdoc.org/d/seancorfield/next.jdbc/1.0.445/doc/getting-started/tips-tricks#working-with-json-and-jsonb but I get: Could not find namespace: next.jdbc.result-set.

borkdude13:02:12

@anthony-galea I think this should be improved in the sql-pods probably. Feel free to post an issue. For now you could maybe coerce the JSON into a string in the query first

borkdude13:02:30

What causes the issue: a json(b) field is represented by some PGobject, but this PGobject isn't converted into EDN automatically so it's trying to be sent over the wire as EDN but this doesn't work when you read it back in

borkdude13:02:36

We can decide to automatically convert the PGobject to a Clojure value, but this would involve making some pre-determined choices which might cause surprises for the user?

borkdude13:02:14

so instead you can select the field as text using ::text and then do the conversion yourself

borkdude13:02:48

We should either fix this or document this. Happy to hear your feedback.

anthony-galea13:02:31

I think the ::text route should be fine in my case @borkdude, thanks!

anthony-galea14:02:17

Great, thanks @borkdude Meanwhile I can confirm that the ::text route worked fine for my usecase

anthony-galea14:02:21

Just out of curiosity, is there some reason that the next.jdbc nss are not available though?

borkdude14:02:45

It's just that someone hasn't asked about it before probably

borkdude14:02:08

Please post an issue of what you need + optionally a PR

anthony-galea14:02:18

Will do, thanks again

borkdude15:02:54

๐Ÿš€ 8
๐Ÿ’ฏ 1
๐Ÿ˜„ 1
grazfather15:02:41

thatโ€™s beautiful