Hi, hstore have only key-value pairs, but in json can have same behavior - only equal objects are removed:
SELECT '{"a": 1, "b": {"c": 2}}'::JSONB - '{"a": 1, "b": {"c": 3}}'::JSONB '{"b": {"c": 2}}' SELECT '{"a": 1, "b": {"c": 2}}'::JSONB - '{"a": 2, "b": {"c": 2}}'::JSONB '{"a": 1}' David -- ------------------------------------- Ing. David TUROŇ LinuxBox.cz, s.r.o. 28. rijna 168, 709 01 Ostrava tel.: +420 591 166 224 fax: +420 596 621 273 mobil: +420 732 589 152 www.linuxbox.cz mobil servis: +420 737 238 656 email servis: ser...@linuxbox.cz ------------------------------------- Od: David Fetter <da...@fetter.org> Komu: david.tu...@linuxbox.cz Kopie: pgsql-hackers@postgresql.org Datum: 18. 07. 2017 18:24 Předmět: Re: [HACKERS] JSONB - JSONB operator feature request On Tue, Jul 18, 2017 at 01:36:32PM +0200, david.tu...@linuxbox.cz wrote: > Hi, > > some users and me used hstore - hstore for example storing only changed > rows in trigger like: > > hstore(NEW) - hstore(OLD) > > There isn't same operator/function in JSON/JSONB. We can only remove keys > from JSONB, but not equal key-value pairs. Is there any chance to have > same feature with JSON/JSONB in postgres core? What would - mean precisely for JSON[B]? For example, what would you expect SELECT '{"a": 1, "b": {"c": 2}}'::JSONB - '{"b": 1, "b": {"c": 3}}'::JSONB to yield? Best, David. -- David Fetter <david(at)fetter(dot)org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate