Return keys for values with dot-separation in joined statements

Поиск
Список
Период
Сортировка
От Alexander Reichstadt
Тема Return keys for values with dot-separation in joined statements
Дата
Msg-id EDF43DE5-F8AC-4A7A-A8CC-6DF9CED5D2E1@mac.com
обсуждение исходный текст
Ответы Re: Return keys for values with dot-separation in joined statements  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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

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

Предыдущее
От: Ivan Sergio Borgonovo
Дата:
Сообщение: fsync default setting and version
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Return keys for values with dot-separation in joined statements