Fork me on GitHub
#sql
<
2021-03-24
>
futuro14:03:15

Is there an option to pass somewhere in next.jdbc to automatically convert JSONB columns from postgres, but that doesn't involve extending the result-set/ReadableColumn protocol?

futuro14:03:25

We're currently extending that protocol, but I'm wondering if there's a more functional, less protocol based method of achieving the same result of JSONB column values being converted to EDN automatically on SELECT calls

lukasz14:03:44

Why protocols are a problem?

richiardiandrea01:03:42

just as additional data point, I have also found the protocol way a bit clunky...plus it's global - that might be a disadvantage, depending of course on what you are doing...not a big deal anyways

futuro14:03:33

Not a problem, per se, but the side-affecting nature of loading a namespace with protocol extensions has me wondering if there's a way without protocols.

futuro14:03:23

Specifically, forcing everyone to have json column values parsed in the same way has me wondering about alternatives.

lukasz14:03:12

The functional alternative is to... have a function which wraps your query functions and parses JSONB columns, right? I'd assume that's less performant though (I might be wrong, I prefer to extend the protocol and not worry about wrapping my functions to properly (de)serialize JSON columns).

futuro14:03:00

I'm not sure about the performance impact, though I also assume it'd be slower.

futuro14:03:20

I don't have any data to back that up though.

seancorfield16:03:53

You could write a builder adapter that applied the conversion and then use default options if you wanted to make that builder your default (for a given datasource). There are caveats, and it’s probably a lot more work, but it is doable.

futuro20:03:56

That's good to know, thank you. I'll start with protocols and keep that in mind if/when we need to switch away from them.