Closed mqp closed 1 year ago
Do you have any interest in this kind of work? I have a project that makes heavy use of JSON columns, and I need to decide whether to try to contribute JSON column QoL improvements upstream like this, or whether I should maintain a fork.
Hey, sorry for the late response! Yes, we definitely need this - will take a look later today.
:tada: This PR is included in version 1.2.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Hey, sorry for the late response! Yes, we definitely need this - will take a look later today.
<3
Postgres supports accessing properties in JSON and JSONB columns by using the
->
and->>
operators. Postgrest supports this too. However, trying to use this in the Supabaseselect
API makes Typescript barf:This small extension to the query parser types makes simple
column->foo->bar->>baz
property chains work properly, e.g. the above query will infer a type of{ username: Json, numLikes: string }
.Note that this doesn't currently work in combination with embedded fields or renaming -- the query parser types would realistically need to be refactored to accomplish that without a serious amount of cut-and-pasted code. I aimed to just hit the common case and scratch my own itch with minimal effort here.