From: | RODRIGUEZ CORTES MARIO IGNACIO <IGNACIO(dot)CORTES(at)inegi(dot)org(dot)mx> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | problem changing jsonb attribute to null value |
Date: | 2017-11-15 21:54:31 |
Message-ID: | 1510782840.2563.27.camel@inegi.org.mx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello:
I have a problem with a record in a jsonb type table, I'm trying to
change the value of an attribute to null but it leaves me all the
content in null and not just the value, I show you an example first of
how to define the null attribute:
prueba=# select jsonb_build_object('v', null);
jsonb_build_object
--------------------
{"v": null}
(1 fila)
this jsonb record is correct, then when trying to change the value with
jsonb_set with some value of type jsonb, it does it correctly:
prueba=# select jsonb_set('{"v" : 0}'::jsonb, '{"v"}', to_jsonb(1));
jsonb_set
-----------
{"v": 1}
(1 fila)
but if i try to put the null value in "v" attribute, apparently is not
allowed:
prueba=# select jsonb_set('{"v" : 0}'::jsonb, '{"v"}', to_jsonb(null));
ERROR: no se pudo determinar el tipo polimórfico porque el tipo de
entrada es «unknown»
defining null value as a text type:
prueba=# select jsonb_set('{"v" : 0}'::jsonb, '{"v"}',
to_jsonb(null::text));
jsonb_set
-----------
(1 fila)
it leaves the record in null, when I hope it leaves it with the null
value in attribute "v": {"v": null}
thank you for your help!!!!
Regards!!!!
From | Date | Subject | |
---|---|---|---|
Next Message | Dmitry Dolgov | 2017-11-15 22:07:01 | Re: problem changing jsonb attribute to null value |
Previous Message | rammohan ganapavarapu | 2017-11-15 21:23:57 | Re: Can master and slave on different PG versions? |