3 ms·
One of the restrictions of composite types is that they can not contain an instance of themselves. So unfortunately, this is not currently possible. I had this
by oliverrice 4y ago
One of the restrictions of composite types is that they can not contain an instance of themselves. So unfortunately, this is not currently possible.
I had this issue when trying to implement an AST type for pg_graphql[1] back when it was written in SQL [2]. In the end we used a JSON type which was much less constrained. That might be solvable using pg_jsonschema [3] if you really wanted to have a good time though
[1] https://github.com/supabase/pg_graphql https://github.com/supabase/pg_graphql
[2] https://github.com/supabase/pg_graphql/blob/34cc266da972d356365f953503deb7a39960da0a/pg_graphql--0.4.0.sql https://github.com/supabase/pg_graphql/blob/34cc266da972d356...
[3] https://github.com/supabase/pg_jsonschema https://github.com/supabase/pg_jsonschema
- nextaccountic 4y agoWhat's your opinion between jsonb vs hstore columns? https://www.postgresql.org/docs/15/hstore.html https://www.postgresql.org/docs/15/hstore.html
- oliverrice 4y agoIIRC, hstore pre-dated jsonb. I'm not aware of any performance differences for the object type but it would be worth checking if you have a heavy workload. jsonb will tend to have better ORM support and it also isn't behind an extension which is a (small) perk
- nextaccountic 4y agoActually, another thing. JSON works. But what about doing pattern matching on the tagged enum? Each variant should give access to its fields Can https://www.postgresql.org/docs/15/functions-conditional.html https://www.postgresql.org/docs/15/functions-conditional.htm... be used to do it?