This could be useful in case you want to port a babashka script to deps.edn and want to compile it with GraalVM, perhaps.
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.
@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
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
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?
so instead you can select the field as text using ::text
and then do the conversion yourself
We should either fix this or document this. Happy to hear your feedback.
I think the ::text
route should be fine in my case @borkdude, thanks!
@anthony-galea Added some docs here: https://github.com/babashka/babashka-sql-pods/#troubleshooting
Great, thanks @borkdude Meanwhile I can confirm that the ::text
route worked fine for my usecase
Just out of curiosity, is there some reason that the next.jdbc nss are not available though?
It's just that someone hasn't asked about it before probably
Please post an issue of what you need + optionally a PR
Will do, thanks again
@emilien ^ :)
thatβs beautiful