pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedbug in jsonb_set porstgresql 5.5
3+ messages / 3 participants
[nested] [flat]
* bug in jsonb_set porstgresql 5.5
@ 2018-02-22 13:38 Pascal Barbedor <pbarbedor@blset.com>
0 siblings, 2 replies; 3+ messages in thread
From: Pascal Barbedor @ 2018-02-22 13:38 UTC (permalink / raw)
To: pgsql-bugs
Hello
I noticed a problem with a jsonb field and jsonb_set function
- table1 is a table with history a jsonb field, and obs a text field which is null
Those three instructions were sent to postgresql
1- this one is ok, set the field to an empty object
update table1 set history=‘{}’
2- this one is ok, creates a key q1 initialized at an empty object
update table1 set history=jsonb_set(history,’{q1}’, ‘{}’)
3- this one resets completely the jsonb field, not only the key obs is not set to null but the entire jsonb field is now null
update table1 set history=jsonb_set(history,’{q1,obs}’, to_jsonb(obs))
this is on postgresql 5.5
Best regards
Pascal BARBEDOR
tel 01 45 34 55 25
mob 06 82 32 69 63
http://www.blset.com
tel 01 46 23 86 74
fax 09 72 42 01 93
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: bug in jsonb_set porstgresql 5.5
@ 2018-02-22 15:42 David G. Johnston <david.g.johnston@gmail.com>
parent: Pascal Barbedor <pbarbedor@blset.com>
1 sibling, 0 replies; 3+ messages in thread
From: David G. Johnston @ 2018-02-22 15:42 UTC (permalink / raw)
To: Pascal Barbedor <pbarbedor@blset.com>; +Cc: pgsql-bugs
On Thu, Feb 22, 2018 at 6:38 AM, Pascal Barbedor <pbarbedor@blset.com>
wrote:
> Hello
>
>
> I noticed a problem with a jsonb field and jsonb_set function
>
>
> - table1 is a table with *history* a jsonb field, and *obs* a text field
> which is null
>
> [...]
> *3- this one resets completely the jsonb field, not only the key obs is
> not set to null but the entire jsonb field is now null*
>
> *update table1 set history=jsonb_set(history,’{q1,obs}’, to_jsonb(obs))*
>
Working as designed - jsonb_set and to_jsonb are both defined as "NULL ON
NULL INPUT (i.e., STRICT)" - since "obs [is] a text field which is null"
the final result of the function call is NULL.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: bug in jsonb_set porstgresql 5.5
@ 2018-02-22 15:51 Thomas Kellerer <spam_eater@gmx.net>
parent: Pascal Barbedor <pbarbedor@blset.com>
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Kellerer @ 2018-02-22 15:51 UTC (permalink / raw)
To: pgsql-bugs
Pascal Barbedor schrieb am 22.02.2018 um 14:38:
> I noticed a problem with a jsonb field and jsonb_set function
>
> - table1 is a table with *history* a jsonb field, and *obs* a text field which is null
>
> Those three instructions were sent to postgresql
>
> 1- this one is ok, set the field to an empty object
> *update table1 set history=‘{}’*
>
> 2- this one is ok, creates a key q1 initialized at an empty object
> *update table1 set history=jsonb_set(history,’{q1}’, ‘{}’)*
>
> *3- this one resets completely the jsonb field, not only the key obs is not set to null but the entire jsonb field is now null*
> *
> *
> *update table1 set history=jsonb_set(history,’{q1,obs}’, to_jsonb(obs))*
>
> this is on postgresql 5.5
There is no PostgreSQL 5.5 (and never was if I'm not mistaken)
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2018-02-22 15:51 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 13:38 bug in jsonb_set porstgresql 5.5 Pascal Barbedor <pbarbedor@blset.com>
2018-02-22 15:42 ` David G. Johnston <david.g.johnston@gmail.com>
2018-02-22 15:51 ` Thomas Kellerer <spam_eater@gmx.net>
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