Thread: BUG #14449: inconsistency in behaviour of json/jsonb returning functions for sql NULL and json NULL values
BUG #14449: inconsistency in behaviour of json/jsonb returning functions for sql NULL and json NULL values
From
rainer.steinmueller@kit.edu
Date:
VGhlIGZvbGxvd2luZyBidWcgaGFzIGJlZW4gbG9nZ2VkIG9uIHRoZSB3ZWJz aXRlOgoKQnVnIHJlZmVyZW5jZTogICAgICAxNDQ0OQpMb2dnZWQgYnk6ICAg ICAgICAgIFJhaW5lciBTdGVpbm3DvGxsZXIKRW1haWwgYWRkcmVzczogICAg ICByYWluZXIuc3RlaW5tdWVsbGVyQGtpdC5lZHUKUG9zdGdyZVNRTCB2ZXJz aW9uOiA5LjYuMQpPcGVyYXRpbmcgc3lzdGVtOiAgIERlYmlhbiAzLjE2LjM2 LTErZGViOHUyIHg4Nl82NCBHTlUvTGludXgKRGVzY3JpcHRpb246ICAgICAg ICAKCiMgYWxsIHRoZSBmb2xsb3dpbmcgc3FsIHN0YXRlbWVudHMgYXJlIHRl c3RlZCB3aXRoIHBzcWwuDQojIHRyeSB0byBjYXN0IG9yIHRvIGNvbnZlcnQg YSBzcWwgTlVMTCB2YWx1ZSB0byBqc29uL2pzb25iIG51bGwgZG9lcyBub3QK Z2VuZXJhdGUgdGhlIGRlc2lyZWQgcmVzdWx0Og0KDQpuZXQ9PiBzZWxlY3Qg dG9fanNvbmIobnVsbDo6dGV4dCk7DQogdG9fanNvbmINCi0tLS0tLS0tLS0N Cg0KKDEgcm93KQ0KDQojIHRoaXMgaXMgdGhlIGNvcnJlY3QgcmVzdWx0Og0K DQpuZXQ9PiBzZWxlY3QganNvbmJfYnVpbGRfb2JqZWN0KCdmMScsIG51bGwp IC0+ICdmMSc7DQogP2NvbHVtbj8NCi0tLS0tLS0tLS0NCiBudWxsDQooMSBy b3cpDQoNCg0KIyB0aGUgc2FtZSBiZWhhdmlvdXIgZm9yIG1hbmlwdWxhdGlu ZyBqc29uYjoNCiMgdGhpcyBzdGF0ZW1lbnQgZG9lcyBub3Q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gY29u dmVydCBpbXBsaWNpdGx5KS4NCgoK
Re: BUG #14449: inconsistency in behaviour of json/jsonb returning functions for sql NULL and json NULL values
From
"David G. Johnston"
Date:
On Mon, Dec 5, 2016 at 10:53 AM, <rainer.steinmueller@kit.edu> wrote: > The following bug has been logged on the website: > > Bug reference: 14449 > Logged by: Rainer Steinm=C3=BCller > Email address: rainer.steinmueller@kit.edu > PostgreSQL version: 9.6.1 > Operating system: Debian 3.16.36-1+deb8u2 x86_64 GNU/Linux > Description: > > # all the following sql statements are tested with psql. > # try to cast or to convert a sql NULL value to json/jsonb null does not > generate the desired result: > > net=3D> select to_jsonb(null::text); > to_jsonb > ---------- > > (1 row) > =E2=80=8BPrevious discussion on -hackers on this topic. https://www.postgresql.org/message-id/CAFj8pRBdi4Ud-%3D8kfM28i7fa%3DB6t%3Dn= FTM3UK5qNBm9TjazC99A%40mail.gmail.com =E2=80=8BThe general conclusion is that the benefit of making this consiste= nt outweighs the effort to define that consistency and introduce a breakage in compatibility.=E2=80=8B David J.