datagrip view postgresql jsonb array in pretty?

Answered

datagrip can view json in pretty, but can not view json array in pretty.

Has this been implemented or we have to looking forward a future releases?

 

0
5 comments

wangxiang,

I can't reproduce the issue with the following SQL. Could you specify our IDE version and sample DDL & DML to reproduce the issue?

CREATE TABLE public.purchases
(
id serial PRIMARY KEY,
purchaser varchar(50),
items_purchased jsonb
);

INSERT INTO purchases (purchaser,items_purchased) VALUES ('Bob',
'[{
"productid": 1,
"name": "Dell 123 Laptop Computer",
"price": 1300},
{
"productid": 2,
"name": "Mechanical Keyboard",
"price": 120}
]');
INSERT INTO purchases (purchaser,items_purchased) VALUES('Carol',
'[{
"productid": 3,
"name": "Virtual Keyboard",
"price": 150}, {
"productid": 1,
"name": "Dell 123 Laptop Computer",
"price": 1300},
{
"productid": 8,
"name": "LG Ultrawide Monitor",
"price": 190}
]');INSERT INTO purchases (purchaser,items_purchased) VALUES ('Ted',
'[{
"productid": 6,
"name": "Ergonomic Keyboard",
"price": 90},
{
"productid": 7,
"name": "Dell 789 Desktop Computer",
"price": 120}
]');
INSERT INTO purchases (purchaser,items_purchased) VALUES('Alice',
'[{
"productid": 7,
"name": "Dell 789 Desktop Computer",
"price": 120},
{
"productid": 2,
"name": "Mechanical Keyboard",
"price": 120}
]');

0

vasily chernov

I use datagrip built in latest version pycharm.

my column type is `jsonb array`, this array type  can not be pretty now.

may be I should consider use jsonb instead

 

 

0

wangxiang Please provide the table definition and a sample DML query for populating with json b array data. We'll try to reproduce this behavior.

0

vasily chernov Aleksandr Molchanov

the DML query is as below

create table public.test_table
(
    id   serial primary key,
    work_settings    jsonb[]    default ARRAY []::jsonb[]  not null
);

insert into test_table(work_settings)
values (array['{"name":"Bob","age":18}','{"name":"Alice","age":20}']::json[]);
select work_settings from test_table;
select work_settings[1] from test_table;

 

 

0

wangxiang Thanks for the provided information.

I may confirm that the jsonb array is not retaining the structure with formatting for this data type in DataGrip(2023.1.2 and EAP versions). This is partially related to this issue

So, for now, as a workaround, I'd encourage using jsonb instead of jsonb array.

0

Please sign in to leave a comment.