From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | Israel Brewster <ibrewster(at)flyravn(dot)com> |
Cc: | "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org> |
Subject: | Re: RealDictCursor behavior question |
Date: | 2018-04-30 18:58:02 |
Message-ID: | CA+mi_8a=pODjaDrugGEmjy0M1JamXye2NapUMeTCpX6-5AsoqA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On Mon, Apr 30, 2018 at 7:18 PM, Israel Brewster <ibrewster(at)flyravn(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Israel Brewster | 2018-04-30 19:19:46 | Re: RealDictCursor behavior question |
Previous Message | Christophe Pettus | 2018-04-30 18:19:34 | Re: RealDictCursor behavior question |