3 ms·
This is my pet peeve with SQL. I hope some day PostgreSQL gain support for native tagged unions. I have saved some links about this https://github.com/solidsn
by nextaccountic 4y ago
This is my pet peeve with SQL. I hope some day PostgreSQL gain support for native tagged unions.
I have saved some links about this
https://github.com/solidsnack/pg-sql-variants https://github.com/solidsnack/pg-sql-variants
https://thelyfsoshort.io/variant-types-in-postgresql-c63725f8678b https://thelyfsoshort.io/variant-types-in-postgresql-c63725f...
https://www.parsonsmatt.org/2019/03/19/sum_types_in_sql.html https://www.parsonsmatt.org/2019/03/19/sum_types_in_sql.html
https://typeable.io/blog/2019-11-21-sql-sum-types.html https://typeable.io/blog/2019-11-21-sql-sum-types.html
Right now I think the ideal is a jsonb column (with a field that stores the tag) plus
https://github.com/supabase/pg_jsonschema https://github.com/supabase/pg_jsonschema. But this is only usable if your language translates to/from JSON and generates json schema for you.
Rust can do this with https://serde.rs/ https://serde.rs/ and https://docs.rs/schemars/latest/schemars/ https://docs.rs/schemars/latest/schemars/