Re: RealDictCursor behavior question

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: RealDictCursor behavior question
Дата
Msg-id CA+mi_8a=pODjaDrugGEmjy0M1JamXye2NapUMeTCpX6-5AsoqA@mail.gmail.com
обсуждение исходный текст
Ответ на RealDictCursor behavior question  (Israel Brewster <ibrewster@flyravn.com>)
Ответы Re: RealDictCursor behavior question  (Israel Brewster <ibrewster@flyravn.com>)
Список psycopg
On Mon, Apr 30, 2018 at 7:18 PM, Israel Brewster <ibrewster@flyravn.com> wrote:
When using the RealDictCursor from psycopg2 extras, is the behavior of RealDictCursor well defined for the case where you have repeated column names (such as in a join)? That is, obviously a dictionary can only have one value for a key, so is it safe to assume that the value for the column name key in the case of repeated column names is always going to be the one that appears LAST in the query?

Not at all: the result is at best an error, at worse an undefined behaviour. Even if at the moment the result appears consistent we may change the implementation in the future.

Do specify explicit names for the columns, and never use `select *` in production, which may result in accidental duplications (maybe not now, but in the future, when you add an apparently unrelated field to a table and grep can't help you).


-- Daniele

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

Предыдущее
От: Christophe Pettus
Дата:
Сообщение: Re: RealDictCursor behavior question
Следующее
От: Israel Brewster
Дата:
Сообщение: Re: RealDictCursor behavior question