pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15075: jsonb_set return [null] if new value is null but not 'null'.
2+ messages / 2 participants
[nested] [flat]
* BUG #15075: jsonb_set return [null] if new value is null but not 'null'.
@ 2018-02-19 08:33 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2018-02-19 08:33 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: claudel.sylvain@gmail.com
The following bug has been logged on the website:
Bug reference: 15075
Logged by: Sylvain Claudel
Email address: claudel.sylvain@gmail.com
PostgreSQL version: 10.1
Operating system: MacOSX
Description:
This behavior is it normal ?
select jsonb_set('{"f1":1,"f2":null,"f3":"bidule"}', '{f3}', null, false);
#> [null]
select jsonb_set('{"f1":1,"f2":null,"f3":"bidule"}', '{f3}', 'null',
false);
#> {"f1":1,"f2":null,"f3":null}
In a update query, it is dangerous.
It may be better that the request crashes rather than executing with
surprising behavior.
Tested in postgresql 9.6.4 and 10.1 but nothing on the changelog concerning
jsonb_set since 9.6.1.
Sorry if this report is not "clean".
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #15075: jsonb_set return [null] if new value is null but not 'null'.
@ 2018-02-19 09:18 Michael Paquier <michael@paquier.xyz>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Paquier @ 2018-02-19 09:18 UTC (permalink / raw)
To: claudel.sylvain@gmail.com; pgsql-bugs@lists.postgresql.org
On Mon, Feb 19, 2018 at 08:33:49AM +0000, PG Bug reporting form wrote:
> Is this behavior normal ?
>
> select jsonb_set('{"f1":1,"f2":null,"f3":"bidule"}', '{f3}', null, false);
> #> [null]
> select jsonb_set('{"f1":1,"f2":null,"f3":"bidule"}', '{f3}', 'null',
> false);
> #> {"f1":1,"f2":null,"f3":null}
>
> In a update query, it is dangerous.
> It may be better that the request crashes rather than executing with
> surprising behavior.
jsonb_set is a strict function, meaning that any NULL value from input
arguments will make the function return NULL as result, which is what
your first example does. In the second query, you are using null as
JSON value, which is actually valid as input. So as far as I can see,
this is normal.
> Sorry if this report is not "clean".
No problem. I have been able to decrypt it easily :)
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-02-19 09:18 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 08:33 BUG #15075: jsonb_set return [null] if new value is null but not 'null'. PG Bug reporting form <noreply@postgresql.org>
2018-02-19 09:18 ` Michael Paquier <michael@paquier.xyz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox