Join using a json value with postgres
I have this table:
I'm trying to write this join:
But I get this error on the key(id):
and this one the o.id:
12 Replies
Or alternatively
But it seems that the
details
object doesn't have an column id
in your types.yeah, the generated type seems to be just generic json
Yeah the type generator can't know the shape of the JSON object.
What kind of type does the generator generate?
so just any json data
which makes sense I guess, but how do people do this generally? A hand-rolled type for the json?
looks like there is an open issue: https://github.com/RobinBlomberg/kysely-codegen/issues/75
GitHub
Define types for JSON columns · Issue #75 · RobinBlomberg/kysely-co...
Hey!, First thanks for creating this tool - saves time for sure! This is probably similar to #30 However that seemed focused on deriving the types from ENUMs and headed down a different path. I was...
Oh crap.. Yeah that's not compatible with the JSON reference builder
so for this to work, you would have to manually define the type, yeah?
For now you can use this:
cool, that works, thanks!
I don't know much about json in postgres, do json columns have a schema?
Nope
They are just opaque blobs
I think it would actually be better if the type generator typed them as
any
so the only way to support this with codegen is have some way of passing in a type of json objects
hmm
That'd also work with kysely
Or
unknown
We could make that work