rel8 icon indicating copy to clipboard operation
rel8 copied to clipboard

Unable to select from functions

Open intolerable opened this issue 3 years ago • 4 comments

As mentioned by @ocharles here, it's not yet possible to select from a function result. This is something that will be fairly critical for constructing more complex JSON-related queries.

intolerable avatar Jun 22 '21 18:06 intolerable

I think this is actually possible in Opaleye, we need to use the RepExpr constructor of PrimQuery.

shane-circuithub avatar Jun 23 '21 10:06 shane-circuithub

Yea, I think I mentioned that in private on Slack - but I'm not even sure if Opaleye uses that constructor! Maybe just left-over from forking from HaskellDB :) Either way, that looks like the right tool.

ocharles avatar Jun 23 '21 11:06 ocharles

relExpr postdates HaskellDB and is supposed to work but I'm not sure if anyone uses it in practice.

tomjaguarpaw avatar Jun 25 '21 16:06 tomjaguarpaw

I've just run into this issue too, I was wondering if it's possible to treat a field which is JSONBEncoded as something I can query into and treat fields as expressions themselves. It looks like Opaleye has support for dealing with JSON(B) encoded columns and pulling out data, but I'm not sure how to tap into the underlying structure.

Does anyone have any example code for haw you might be able to do that?

This would be a killer app for us if we could use it, we have a lot of tables with the same schema where each table has some metadata columns and a payload column as JSONB.

ghost avatar Jul 06 '21 00:07 ghost