BUG #13937: 'src' -> jsonb_each() -> jsonb_object() -> 'dst' does not recreate 'src' as valid jsonb
От | xtracoder@gmail.com |
---|---|
Тема | BUG #13937: 'src' -> jsonb_each() -> jsonb_object() -> 'dst' does not recreate 'src' as valid jsonb |
Дата | |
Msg-id | 20160208202959.2662.26227@wrigleys.postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #13937: 'src' -> jsonb_each() -> jsonb_object() ->
'dst' does not recreate 'src' as valid jsonb
Re: BUG #13937: 'src' -> jsonb_each() -> jsonb_object() -> 'dst' does not recreate 'src' as valid jsonb |
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 13937 Logged by: Xtra Coder Email address: xtracoder@gmail.com PostgreSQL version: 9.5.0 Operating system: Windows7 Description: Steps to reproduce: ------------------- DO LANGUAGE plpgsql $$ DECLARE jsonb_src jsonb; jsonb_dst jsonb; BEGIN jsonb_src = '{ "key1": {"data1": [1, 2, 3]}, "key2": {"data2": [3, 4, 5]} }'; raise notice 'jsonb_src = %', jsonb_src; with t_data as (select * from jsonb_each(jsonb_src)) select jsonb_object( array(select key from t_data), array(select value::text from t_data) ) into jsonb_dst; raise notice 'jsonb_dst = %', jsonb_dst; END $$; Actual result: -------------- NOTICE: jsonb_src = {"key1": {"data1": [1, 2, 3]}, "key2": {"data2": [3, 4, 5]}} NOTICE: jsonb_dst = {"key1": "{\"data1\": [1, 2, 3]}", "key2": "{\"data2\": [3, 4, 5]}"} What's wrong? - values in 'dst' are represented as text. Reason - jsonb_object() has arguments as jsonb_object(keys text[], values text[]) and there is no way to pass values as 'jsonb'. Conversion to 'text' looses JSON structure. Expected result: ---------------- NOTICE: jsonb_src = {"key1": {"data1": [1, 2, 3]}, "key2": {"data2": [3, 4, 5]}} NOTICE: jsonb_dst = {"key1": {"data1": [1, 2, 3]}, "key2": {"data2": [3, 4, 5]}} 'src' and 'dst' JSON objects should be identical/equal.
В списке pgsql-bugs по дате отправления: