Search Postgresql Archives

Re: Possible bug with row_to_json

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 5, 2013 at 5:15 PM, Jack Christensen
<jack@xxxxxxxxxxxxxxxxxxx> 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux