Re: RealDictCursor behavior question

From: Christophe Pettus <xof(at)thebuild(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:19:34
Message-ID: D3CD577E-4339-49A4-8AFA-5435BA0AA7E8@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg


> On Apr 30, 2018, at 11:18, 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?

I don't believe it is guaranteed. The best approach is to rename duplicate column names using AS so you are sure you are getting back what you expect.

--
-- Christophe Pettus
xof(at)thebuild(dot)com

In response to

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2018-04-30 18:58:02 Re: RealDictCursor behavior question
Previous Message Israel Brewster 2018-04-30 18:18:13 RealDictCursor behavior question