Re: RealDictCursor behavior question - Mailing list psycopg

From Daniele Varrazzo
Subject Re: RealDictCursor behavior question
Date
Msg-id CA+mi_8a=pODjaDrugGEmjy0M1JamXye2NapUMeTCpX6-5AsoqA@mail.gmail.com
Whole thread Raw
In response to RealDictCursor behavior question  (Israel Brewster <ibrewster@flyravn.com>)
Responses Re: RealDictCursor behavior question
List 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 by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: RealDictCursor behavior question
Next
From: Israel Brewster
Date:
Subject: Re: RealDictCursor behavior question