Re: BUG #13533: jsonb_populate_record does not work when the value is a simple string - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #13533: jsonb_populate_record does not work when the value is a simple string
Date
Msg-id 9283.1438620012@sss.pgh.pa.us
Whole thread Raw
In response to BUG #13533: jsonb_populate_record does not work when the value is a simple string  (paulovieira@gmail.com)
List pgsql-bugs
paulovieira@gmail.com writes:
> drop table if exists temp_table;
> create table temp_table(id int, data json);

> do $$

> declare
>   input_data json := '{"id": 1, "data": "abc"}';
>   input_row temp_table%ROWTYPE;

> begin
>   for input_row in (select * from
> json_populate_record(null::temp_table,input_data)) loop
>     raise notice '%', input_row.data;
>   end loop;
> end

> $$;

> ERROR:  22P02: invalid input syntax for type json
> DETAIL:  Token "abc" is invalid.

This does not seem like a bug, because the value of the data field is
just abc, and that isn't JSON.  You'd need something more like

   input_data json := '{"id": 1, "data": "\"abc\""}';

            regards, tom lane

pgsql-bugs by date:

Previous
From: Francisco Olarte
Date:
Subject: Re: BUG #13534: Pgadmin crash when changing font
Next
From: lthompson@alteryx.com
Date:
Subject: BUG #13536: SQLParamData thows "Invalid Endian" error