sql

hanDerPeder 2024-03-21T19:28:37.628189Z

I have a postgres table with a jsonb column that I want to return directly to clients. Is it possible to just pass the data through withouth next.jdbc touching it? we have this guy installed which I don't want to be executed in this case

(extend-protocol rs/ReadableColumn
  PGobject
  (read-column-by-label [^PGobject v _]
    (<-pgobject v))
  (read-column-by-index [^PGobject v _2 _3]
    (<-pgobject v)))

seancorfield 2024-03-21T20:12:48.213539Z

Protocols are "global" so, no. You'd need to modify the protocol to not convert the specific column.

👍 1
hanDerPeder 2024-03-21T20:15:22.251219Z

So without this guy, next.jdbc would return what? string? bytearray?

hanDerPeder 2024-03-21T20:15:55.860069Z

probably PGobject facepalm

seancorfield 2024-03-21T20:16:08.694739Z

Yup, plain ol' PGObject...

seancorfield 2024-03-21T20:16:35.630799Z

I guess it depends on what you mean by "jsonb column that I want to return directly to clients"...?

seancorfield 2024-03-21T20:17:08.848929Z

You may be able to CAST() it to something in SQL that avoided the PGObject decoding, but returns something useful?

💯 1
hanDerPeder 2024-03-21T20:17:30.534409Z

it's geojson, all nicely laid out for a maplib to consume in the browser.

hanDerPeder 2024-03-21T20:18:23.185909Z

I'll try casting it to bytes, thanks.

isak 2024-03-21T20:18:33.834169Z

Yea you could probably cast it to a string that is json

seancorfield 2024-03-21T20:18:51.391579Z

So instead of PGObject or Clojure data, it sounds like you want regular JSON as a string?

hanDerPeder 2024-03-21T20:19:42.079999Z

yes, ideally a bytestream I can return as the response body

seancorfield 2024-03-21T20:20:17.004519Z

So, right now, you get a Clojure data structure and you have to convert that "back" to JSON for the response?

hanDerPeder 2024-03-21T20:20:30.980329Z

precisely

hanDerPeder 2024-03-21T20:40:34.932309Z

["select geojson::text from t limit 1"]
thanks guys 👍

👍 1
👍🏻 1