json(b) equality rules

Started by Oleg Bartunovalmost 12 years ago7 messages
#1Oleg Bartunov
obartunov@gmail.com

Hi there,

I'm wondering if we should follow all js equility rules as
nicely visualized in
http://strilanc.com/visualization/2014/03/27/Better-JS-Equality-Table.html

Oleg

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

#2Oleg Bartunov
obartunov@gmail.com
In reply to: Oleg Bartunov (#1)
Re: json(b) equality rules

Sure, we don't follow. I mean should we add to documentation
such matrices.

Oleg

On Thu, Apr 3, 2014 at 11:32 AM, Oleg Bartunov <obartunov@gmail.com> wrote:

Hi there,

I'm wondering if we should follow all js equility rules as
nicely visualized in
http://strilanc.com/visualization/2014/03/27/Better-JS-Equality-Table.html

Oleg

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

#3Yeb Havinga
yebhavinga@gmail.com
In reply to: Oleg Bartunov (#2)
Re: json(b) equality rules

On 2014-04-03 09:40, Oleg Bartunov wrote:

Sure, we don't follow. I mean should we add to documentation
such matrices.

Oleg

On Thu, Apr 3, 2014 at 11:32 AM, Oleg Bartunov <obartunov@gmail.com> wrote:

Hi there,

I'm wondering if we should follow all js equility rules as
nicely visualized in
http://strilanc.com/visualization/2014/03/27/Better-JS-Equality-Table.html

Oleg

+1

I was a bit curious what the result would be. A quick inspection of the
query results below gave the impression that the matrix would probably
show a diagonal line. Even though the table is not necessary as a
reference to strange equality rules, a table of equality showing a
diagonal will be easy to remember.

regards,
Yeb

drop table testjsonb;
create table testjsonb(a jsonb);
insert into testjsonb (a) values ('true');
insert into testjsonb (a) values ('false');
insert into testjsonb (a) values ('1');
insert into testjsonb (a) values ('0');
insert into testjsonb (a) values ('-1');
insert into testjsonb (a) values ('"true"');
insert into testjsonb (a) values ('"false"');
insert into testjsonb (a) values ('"1"');
insert into testjsonb (a) values ('"0"');
insert into testjsonb (a) values ('""');
insert into testjsonb (a) values ('null');
insert into testjsonb (a) values ('undefined');
insert into testjsonb (a) values ('Infinity');
insert into testjsonb (a) values ('-Infinity');
insert into testjsonb (a) values ('[]');
insert into testjsonb (a) values ('{}');
insert into testjsonb (a) values ('[{}]');
insert into testjsonb (a) values ('[0]');
insert into testjsonb (a) values ('[1]');
insert into testjsonb (a) values ('NaN');

select a.a, b.a, a.a = b.a
from testjsonb a, testjsonb b

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

#4Oleg Bartunov
obartunov@gmail.com
In reply to: Yeb Havinga (#3)
Re: json(b) equality rules

Well, we don't supported Infinity and NaN in json(b), as well as Json
standard :)
Now we need a script, which generated nice html table.

On Thu, Apr 3, 2014 at 12:40 PM, Yeb Havinga <yebhavinga@gmail.com> wrote:

On 2014-04-03 09:40, Oleg Bartunov wrote:

Sure, we don't follow. I mean should we add to documentation
such matrices.

Oleg

On Thu, Apr 3, 2014 at 11:32 AM, Oleg Bartunov <obartunov@gmail.com>
wrote:

Hi there,

I'm wondering if we should follow all js equility rules as
nicely visualized in

http://strilanc.com/visualization/2014/03/27/Better-JS-Equality-Table.html

Oleg

+1

I was a bit curious what the result would be. A quick inspection of the
query results below gave the impression that the matrix would probably show
a diagonal line. Even though the table is not necessary as a reference to
strange equality rules, a table of equality showing a diagonal will be easy
to remember.

regards,
Yeb

drop table testjsonb;
create table testjsonb(a jsonb);
insert into testjsonb (a) values ('true');
insert into testjsonb (a) values ('false');
insert into testjsonb (a) values ('1');
insert into testjsonb (a) values ('0');
insert into testjsonb (a) values ('-1');
insert into testjsonb (a) values ('"true"');
insert into testjsonb (a) values ('"false"');
insert into testjsonb (a) values ('"1"');
insert into testjsonb (a) values ('"0"');
insert into testjsonb (a) values ('""');
insert into testjsonb (a) values ('null');
insert into testjsonb (a) values ('undefined');
insert into testjsonb (a) values ('Infinity');
insert into testjsonb (a) values ('-Infinity');
insert into testjsonb (a) values ('[]');
insert into testjsonb (a) values ('{}');
insert into testjsonb (a) values ('[{}]');
insert into testjsonb (a) values ('[0]');
insert into testjsonb (a) values ('[1]');
insert into testjsonb (a) values ('NaN');

select a.a, b.a, a.a = b.a
from testjsonb a, testjsonb b

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

#5Andrew Dunstan
andrew@dunslane.net
In reply to: Oleg Bartunov (#4)
Re: json(b) equality rules

On 04/03/2014 05:02 AM, Oleg Bartunov wrote:

Well, we don't supported Infinity and NaN in json(b), as well as Json
standard :)
Now we need a script, which generated nice html table.

(Oleg, please try not to top-post.)

I don't think we should follow these rules at all. Json is not
Javascript, and these are Javascript rules, not Json rules. I'm entirely
opposed to treating 0, "0", false, and [0] as equal. The equality rule
we actually have for jsonb is the correct one, I believe.

cheers

andrew

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

#6Hannu Krosing
hannu@krosing.net
In reply to: Oleg Bartunov (#1)
Re: json(b) equality rules

On 04/03/2014 04:32 AM, Oleg Bartunov wrote:

Hi there,

I'm wondering if we should follow all js equility rules as
nicely visualized in
http://strilanc.com/visualization/2014/03/27/Better-JS-Equality-Table.html

Probably not as JSON is general interchange format.

If somebody wants JavaScript rules, they can use pl/v8

Any equality operations specific for JSON should be related
to array and object/dictionary equality and not data
store inside JSON

Cheers
Hannu

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

#7Peter Geoghegan
pg@heroku.com
In reply to: Andrew Dunstan (#5)
Re: json(b) equality rules

On Thu, Apr 3, 2014 at 7:43 AM, Andrew Dunstan <andrew@dunslane.net> wrote:

I don't think we should follow these rules at all. Json is not Javascript,
and these are Javascript rules, not Json rules. I'm entirely opposed to
treating 0, "0", false, and [0] as equal. The equality rule we actually have
for jsonb is the correct one, I believe.

+1

--
Peter Geoghegan

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