Re: Is there a good way to handle sum types (or tagged unions) in PostgreSQL?

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Is there a good way to handle sum types (or tagged unions) in PostgreSQL?
Дата
Msg-id a585c794-81de-6470-e968-4f52db1567d8@aklaver.com
обсуждение исходный текст
Ответ на Is there a good way to handle sum types (or tagged unions) in PostgreSQL?  (Victor Nordam Suadicani <v.n.suadicani@gmail.com>)
Ответы Re: Is there a good way to handle sum types (or tagged unions) in PostgreSQL?
Список pgsql-general
On 5/18/23 05:27, Victor Nordam Suadicani wrote:
> Hi,
> 
> Is there any nice way to handle sum types (aka tagged unions) in a 
> PostgreSQL database? I've searched far and wide and have not reached any 
> satisfying answer.
> 
> As a (somewhat contrived) example, say I have the following enum in Rust:
> 
> enum TaggedUnion {
>      Variant1(String),
>      Variant2(i32),
>      Variant3(f64),
> }
> 

> If there are no good methods of handling this, is there any way 
> PostgreSQL could be extended with capabilities for this? I have no idea 
> how this would be done in practice though. Perhaps SQL itself is just 
> unsuited for data of this kind? I don't really see why it should be though.

Composite type?:

https://www.postgresql.org/docs/current/rowtypes.html
> 
> Thanks,
> Victor Nordam Suadicani

-- 
Adrian Klaver
adrian.klaver@aklaver.com




В списке pgsql-general по дате отправления:

Предыдущее
От: Brian Mendoza
Дата:
Сообщение: JSONB operator unanticipated behaviour
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: JSONB operator unanticipated behaviour