row_to_json question

Поиск
Список
Период
Сортировка
От Joe Van Dyk
Тема row_to_json question
Дата
Msg-id CACfv+p+UjdKz2s-oAEGJHmNcHxxm=poncXdcEY_tVbU-JnDKnQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: row_to_json question  (Joe Van Dyk <joe@tanga.com>)
Список pgsql-general
How can I use row_to_json for a subset of columns in a row? (without
creating a new view or using a CTE?)

What I want returned:
{"email_address":"joe@tanga.com","username":"joevandyk"}
Note that there is no "id" column in the result.


create table users (id serial primary key, email_address varchar,
username varchar);
insert into users (email_address, username) values ('joe@tanga.com',
'joevandyk');

select row_to_json(users) from users;
 {"id":1,"email_address":"joe@tanga.com","username":"joevandyk"}
      Correct, except that the "id" column is in the result.


select row_to_json(row(users.email_address, users.username)) from users;
 {"f1":"joe@tanga.com","f2":"joevandyk"}
       The column names are incorrect.

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: [ADMIN] Issue in save and retreive file in postgres
Следующее
От: Joe Van Dyk
Дата:
Сообщение: Re: row_to_json question