Return keys for values with dot-separation in joined statements

From: Alexander Reichstadt <lxr(at)mac(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Return keys for values with dot-separation in joined statements
Date: 2012-03-12 16:43:08
Message-ID: EDF43DE5-F8AC-4A7A-A8CC-6DF9CED5D2E1@mac.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

writing a client frontend I started with mysql and migrated to postgres. Now I found out that there is a difference in the way joined queries are returned:

The query

SELECT persons.id,persons.lastname,persons.firstname,persons.salutation,persons.title,addresses.address1,addresses.address2,addresses.city,addresses.zip FROM persons LEFT JOIN addresses_reference ON persons.id=addresses_reference.refid_persons LEFT JOIN addresses ON addresses_reference.refid_addresses=addresses.id LIMIT 106 OFFSET 0

The response from postgres in the API:

address1 = "";
address2 = "";
city = "";
firstname = Olaf;
id = 5;
lastname = Taschenbier;
salutation = Frau;
title = "";
zip = "";

The response from mysql:

persons.address1 = "";
persons.address2 = "";
persons.city = "";
persons.firstname = Olaf;
persons.id = 5;
persons.lastname = Taschenbier;
persons.salutation = Frau;
persons.title = "";
persons.zip = "";

This is especially an issue in cases where two tables do have identical fieldnames. What happens in such cases?

Is there a way or some setting on postgres server to tell postgres to use the fieldnames exactly as provided in the select?

Thanks
Alex

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-03-12 17:09:20 Re: Return keys for values with dot-separation in joined statements
Previous Message Ivan Sergio Borgonovo 2012-03-12 16:16:40 fsync default setting and version