Обсуждение: [pgAdmin4][RM3587] Browser rendering of a bigint in a jsonb is wrong

Поиск
Список
Период
Сортировка

[pgAdmin4][RM3587] Browser rendering of a bigint in a jsonb is wrong

От
Aditya Toshniwal
Дата:
Hi Hackers,

Attached is the patch to fix incorrect rendering of bigint in jsonb. 
The problem is in javascript limitations with big numbers. For fixing, jsonb data will be fetched as string now, similar to json, so that JS will not consider big numbers as number. The only drawback here is that, the popup editor will not show formatted json, as that requires JSON.parse which will change the big numbers.

Kindly review.

Below is sample data for testing:
CREATE TABLE public.tab_jsonbigint
(
    id integer NOT NULL PRIMARY KEY,
    coljsonb jsonb
)

insert into tab_jsonbigint(id, coljsonb) values(3,'[{"a": 83136002445762248}, {"a": 831360024457622448}]');

select d.*, t.coljsonb from tab_jsonbigint t, jsonb_to_recordset(t.coljsonb) as d("a" bigint);



--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"
Вложения

Re: [pgAdmin4][RM3587] Browser rendering of a bigint in a jsonb is wrong

От
Dave Page
Дата:
Hi

On Tue, Feb 26, 2019 at 8:55 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi Hackers,

Attached is the patch to fix incorrect rendering of bigint in jsonb. 
The problem is in javascript limitations with big numbers. For fixing, jsonb data will be fetched as string now, similar to json, so that JS will not consider big numbers as number. The only drawback here is that, the popup editor will not show formatted json, as that requires JSON.parse which will change the big numbers.

Kindly review.

Below is sample data for testing:
CREATE TABLE public.tab_jsonbigint
(
    id integer NOT NULL PRIMARY KEY,
    coljsonb jsonb
)

insert into tab_jsonbigint(id, coljsonb) values(3,'[{"a": 83136002445762248}, {"a": 831360024457622448}]');

select d.*, t.coljsonb from tab_jsonbigint t, jsonb_to_recordset(t.coljsonb) as d("a" bigint);

Hmm, that's unfortunate.

What about using json-bignumber?

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: [pgAdmin4][RM3587] Browser rendering of a bigint in a jsonb is wrong

От
Aditya Toshniwal
Дата:
Hi, 

On Tue, Feb 26, 2019 at 8:04 PM Dave Page <dpage@pgadmin.org> wrote:
Hi

On Tue, Feb 26, 2019 at 8:55 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi Hackers,

Attached is the patch to fix incorrect rendering of bigint in jsonb. 
The problem is in javascript limitations with big numbers. For fixing, jsonb data will be fetched as string now, similar to json, so that JS will not consider big numbers as number. The only drawback here is that, the popup editor will not show formatted json, as that requires JSON.parse which will change the big numbers.

Kindly review.

Below is sample data for testing:
CREATE TABLE public.tab_jsonbigint
(
    id integer NOT NULL PRIMARY KEY,
    coljsonb jsonb
)

insert into tab_jsonbigint(id, coljsonb) values(3,'[{"a": 83136002445762248}, {"a": 831360024457622448}]');

select d.*, t.coljsonb from tab_jsonbigint t, jsonb_to_recordset(t.coljsonb) as d("a" bigint);

Hmm, that's unfortunate.

What about using json-bignumber?
Had thought of using json-bigint similar to json-bignumber, but the question is, do we need add extra overhead of using library for the grid cells?
However, we can use json-big* library only editor pop up and just use plain text when in grid cells.
Will send a updated patch with json-big*.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"

Re: [pgAdmin4][RM3587] Browser rendering of a bigint in a jsonb is wrong

От
Aditya Toshniwal
Дата:
Hi Hackers,

Attached is the updated patch. As mentioned earlier, jsonb will be fetched as text. Only when the pop up editor opens, json-bignumber parser will be used to prettify.
Kindly review.


On Wed, Feb 27, 2019 at 10:12 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi, 

On Tue, Feb 26, 2019 at 8:04 PM Dave Page <dpage@pgadmin.org> wrote:
Hi

On Tue, Feb 26, 2019 at 8:55 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi Hackers,

Attached is the patch to fix incorrect rendering of bigint in jsonb. 
The problem is in javascript limitations with big numbers. For fixing, jsonb data will be fetched as string now, similar to json, so that JS will not consider big numbers as number. The only drawback here is that, the popup editor will not show formatted json, as that requires JSON.parse which will change the big numbers.

Kindly review.

Below is sample data for testing:
CREATE TABLE public.tab_jsonbigint
(
    id integer NOT NULL PRIMARY KEY,
    coljsonb jsonb
)

insert into tab_jsonbigint(id, coljsonb) values(3,'[{"a": 83136002445762248}, {"a": 831360024457622448}]');

select d.*, t.coljsonb from tab_jsonbigint t, jsonb_to_recordset(t.coljsonb) as d("a" bigint);

Hmm, that's unfortunate.

What about using json-bignumber?
Had thought of using json-bigint similar to json-bignumber, but the question is, do we need add extra overhead of using library for the grid cells?
However, we can use json-big* library only editor pop up and just use plain text when in grid cells.
Will send a updated patch with json-big*.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"


--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"
Вложения

Re: [pgAdmin4][RM3587] Browser rendering of a bigint in a jsonb is wrong

От
Dave Page
Дата:
Thanks, patch applied.

On Wed, Feb 27, 2019 at 7:09 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi Hackers,

Attached is the updated patch. As mentioned earlier, jsonb will be fetched as text. Only when the pop up editor opens, json-bignumber parser will be used to prettify.
Kindly review.


On Wed, Feb 27, 2019 at 10:12 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi, 

On Tue, Feb 26, 2019 at 8:04 PM Dave Page <dpage@pgadmin.org> wrote:
Hi

On Tue, Feb 26, 2019 at 8:55 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi Hackers,

Attached is the patch to fix incorrect rendering of bigint in jsonb. 
The problem is in javascript limitations with big numbers. For fixing, jsonb data will be fetched as string now, similar to json, so that JS will not consider big numbers as number. The only drawback here is that, the popup editor will not show formatted json, as that requires JSON.parse which will change the big numbers.

Kindly review.

Below is sample data for testing:
CREATE TABLE public.tab_jsonbigint
(
    id integer NOT NULL PRIMARY KEY,
    coljsonb jsonb
)

insert into tab_jsonbigint(id, coljsonb) values(3,'[{"a": 83136002445762248}, {"a": 831360024457622448}]');

select d.*, t.coljsonb from tab_jsonbigint t, jsonb_to_recordset(t.coljsonb) as d("a" bigint);

Hmm, that's unfortunate.

What about using json-bignumber?
Had thought of using json-bigint similar to json-bignumber, but the question is, do we need add extra overhead of using library for the grid cells?
However, we can use json-big* library only editor pop up and just use plain text when in grid cells.
Will send a updated patch with json-big*.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"


--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"


--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company