Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-09-01 Thread Yeb Havinga
On 30/08/15 04:57, Andrew Dunstan wrote: > > > On 08/29/2015 04:27 PM, Tom Lane wrote: >> I'm not necessarily against changing it --- but it doesn't seem entirely >> black-and-white to me, and we do now have a couple of versions worth >> of precedent we'd be breaking with. >> >> If we do vote to

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Pavel Stehule
2015-08-30 4:57 GMT+02:00 Andrew Dunstan : > > > On 08/29/2015 04:27 PM, Tom Lane wrote: > >> Jim Nasby writes: >> >>> On 8/29/15 12:29 PM, Pavel Stehule wrote: >>> what is correct from JSON perspective? All fields with NULL >>> ISTM that the whole purpose of to_json is to properly json

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Andrew Dunstan
On 08/29/2015 04:27 PM, Tom Lane wrote: Jim Nasby writes: On 8/29/15 12:29 PM, Pavel Stehule wrote: what is correct from JSON perspective? All fields with NULL ISTM that the whole purpose of to_json is to properly jsonify something, and the proper json form for "undefined" is 'null', is it

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread David G. Johnston
On Sat, Aug 29, 2015 at 4:27 PM, Tom Lane wrote: > Jim Nasby writes: > > On 8/29/15 12:29 PM, Pavel Stehule wrote: > >> what is correct from JSON perspective? All fields with NULL > > > ISTM that the whole purpose of to_json is to properly jsonify something, > > and the proper json form for "und

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Jim Nasby
On 8/29/15 3:27 PM, Tom Lane wrote: Jim Nasby writes: On 8/29/15 12:29 PM, Pavel Stehule wrote: what is correct from JSON perspective? All fields with NULL ISTM that the whole purpose of to_json is to properly jsonify something, and the proper json form for "undefined" is 'null', is it not?

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Tom Lane
Jim Nasby writes: > On 8/29/15 12:29 PM, Pavel Stehule wrote: >> what is correct from JSON perspective? All fields with NULL > ISTM that the whole purpose of to_json is to properly jsonify something, > and the proper json form for "undefined" is 'null', is it not? What's not entirely clear is w

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Pavel Stehule
2015-08-29 22:06 GMT+02:00 Jim Nasby : > On 8/29/15 12:29 PM, Pavel Stehule wrote: > >> Note that all the to_json functions are strict. In this sense it's >> quite consistent. If we change it to being called on null input, >> what should we return if a null non-scalar is passed in? >>

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Jim Nasby
On 8/29/15 12:29 PM, Pavel Stehule wrote: Note that all the to_json functions are strict. In this sense it's quite consistent. If we change it to being called on null input, what should we return if a null non-scalar is passed in? what is correct from JSON perspective? All fields wi

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Pavel Stehule
2015-08-29 19:11 GMT+02:00 Andrew Dunstan : > > > On 08/29/2015 12:02 PM, Pavel Stehule wrote: > >> >> >> 2015-08-29 15:43 GMT+02:00 Shulgin, Oleksandr < >> oleksandr.shul...@zalando.de >: >> >> On Sat, Aug 29, 2015 at 3:39 PM, Tom Lane >

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Andrew Dunstan
On 08/29/2015 12:02 PM, Pavel Stehule wrote: 2015-08-29 15:43 GMT+02:00 Shulgin, Oleksandr mailto:oleksandr.shul...@zalando.de>>: On Sat, Aug 29, 2015 at 3:39 PM, Tom Lane mailto:t...@sss.pgh.pa.us>> wrote: Andrew Dunstan mailto:and...@dunslane.net>> writes: > On 08/29

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Jim Nasby
On 8/29/15 11:02 AM, Pavel Stehule wrote: It is bug - and it should be fixed. I agree, so this change is too strong for fixing in minor version - but we can change it in unreleased major versions - 9.5 and master. +1 -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Ana

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Pavel Stehule
2015-08-29 15:43 GMT+02:00 Shulgin, Oleksandr : > On Sat, Aug 29, 2015 at 3:39 PM, Tom Lane wrote: > >> Andrew Dunstan writes: >> > On 08/29/2015 08:47 AM, Shulgin, Oleksandr wrote: >> >> Given there were no loud complaints about this, the current behavior >> >> is appropriate for most users, t

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Shulgin, Oleksandr
On Sat, Aug 29, 2015 at 3:39 PM, Tom Lane wrote: > Andrew Dunstan writes: > > On 08/29/2015 08:47 AM, Shulgin, Oleksandr wrote: > >> Given there were no loud complaints about this, the current behavior > >> is appropriate for most users, the rest can still work around using > >> coalesce(to_json

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Tom Lane
Andrew Dunstan writes: > On 08/29/2015 08:47 AM, Shulgin, Oleksandr wrote: >> Given there were no loud complaints about this, the current behavior >> is appropriate for most users, the rest can still work around using >> coalesce(to_json(...), json 'null'). > I don't think it's necessarily more

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Andrew Dunstan
On 08/29/2015 08:47 AM, Shulgin, Oleksandr wrote: On Sat, Aug 29, 2015 at 8:39 AM, Pavel Stehule mailto:pavel.steh...@gmail.com>> wrote: Hi currently JSON support NULL value - but we doesn't convert NULL to JSON correctly postgres=# select to_json(NULL::text) IS NULL; ┌─

Re: [HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-29 Thread Shulgin, Oleksandr
On Sat, Aug 29, 2015 at 8:39 AM, Pavel Stehule wrote: > Hi > > currently JSON support NULL value - but we doesn't convert NULL to JSON > correctly > > postgres=# select to_json(NULL::text) IS NULL; > ┌──┐ > │ ?column? │ > ╞══╡ > │ t│ > └──┘ > (1 row) > > probably s

[HACKERS] to_json(NULL) should to return JSON null instead NULL

2015-08-28 Thread Pavel Stehule
Hi currently JSON support NULL value - but we doesn't convert NULL to JSON correctly postgres=# select to_json(NULL::text) IS NULL; ┌──┐ │ ?column? │ ╞══╡ │ t│ └──┘ (1 row) probably should be json "null"; like postgres=# select json 'null' is null; ┌──┐