Generic casters for composite types

Поиск
Список
Период
Сортировка
От Ronan Dunklau
Тема Generic casters for composite types
Дата
Msg-id 4EEA0F7F.9030701@gmail.com
обсуждение исходный текст
Ответы Re: Generic casters for composite types  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список psycopg
Hello.

I think it may be interesting to add a generic mechanism for registering
composite type casters.

One of the features I like about postgresql is the ability to perform
queries like this one:

select user_group, array_agg(user) from user_group natural join user
group by user_group

Where user_group and user are two tables related by a foreign key.

Such a query is pleasant to write, but unusable for now because psycopg
returns those values as strings.

Since those types are defined by postgresql at table creation time, it
should be easy to parse those results to return namedtuples.

Would you find a such a feature interesting ? Or is it something that
should be best kept in a distinct library ?

I've attached a small 'proof of concept' file demonstrating how this
could be implemented. The parser implementation is simplistic (and does
not work with complex types), but if this is of interest to you I would
happily work on it.

--
Ronan Dunklau


Вложения

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

Предыдущее
От: Federico Di Gregorio
Дата:
Сообщение: Re: [snafu] isolation-level change in 2.4.2
Следующее
От: Daniele Varrazzo
Дата:
Сообщение: Re: Generic casters for composite types