From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Jack Christensen <jack(at)jackchristensen(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Possible bug with row_to_json |
Date: | 2013-08-05 22:32:41 |
Message-ID: | CAHyXU0xiPVorr5oe5=tqMPQmJXvg9gHNN0ai_APYR0F-Nu7zxA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Mon, Aug 5, 2013 at 5:15 PM, Jack Christensen
<jack(at)jackchristensen(dot)com> wrote:
> When using a subquery as a source for row_to_json, depending on the order of
> arguments it may ignore renaming a column.
>
> jack=# create table player(
> jack(# player_id serial primary key,
> jack(# name varchar not null unique
> jack(# );
> NOTICE: CREATE TABLE will create implicit sequence "player_player_id_seq"
> for serial column "player.player_id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "player_pkey"
> for table "player"
> NOTICE: CREATE TABLE / UNIQUE will create implicit index "player_name_key"
> for table "player"
> CREATE TABLE
> jack=# insert into player(name) values('Jack');
> INSERT 0 1
> jack=# select row_to_json(t)
> jack-# from (
> jack(# select player_id as renamed, name
> jack(# from player
> jack(# order by name
> jack(# ) t;
> row_to_json
> -------------------------------
> {"player_id":1,"name":"Jack"}
> (1 row)
>
>
> It ignored the rename.
>
>
> jack=# select row_to_json(t)
> from (
> select name, player_id as renamed
> from player
> order by name
> ) t;
> row_to_json
> -----------------------------
> {"name":"Jack","renamed":1}
> (1 row)
>
> But here it didn't.
>
> Is this a bug?
yup.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | immersive.excel@gmail.com | 2013-08-05 23:56:48 | Re: Seamless replacement to MySQL's GROUP_CONCAT function... |
Previous Message | Jack Christensen | 2013-08-05 22:15:27 | Possible bug with row_to_json |
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2013-08-05 22:56:16 | Re: Unsafe GUCs and ALTER SYSTEM WAS: Re: ALTER SYSTEM SET |
Previous Message | Jack Christensen | 2013-08-05 22:15:27 | Possible bug with row_to_json |