sql 2024-03-21

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)))

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

👍 1

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

probably PGobject facepalm

Yup, plain ol' PGObject...

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

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

💯 1

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

I'll try casting it to bytes, thanks.

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

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

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

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

precisely

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

👍 1
👍🏻 1