Feature Request: json_extend, jsonb_extend - Mailing list pgsql-general

From Kiswono Prayogo
Subject Feature Request: json_extend, jsonb_extend
Date
Msg-id CANiF8TQ9y5wP7MFYerptSk-P=w=0uaphKvdHRrBY4E7GQOJ_hA@mail.gmail.com
Whole thread Raw
List pgsql-general
It would be nice if PostgreSQL has *_extend (similar to $.extend from jQuery or _.extend from UnderscoreJs) for JSON/JSONB columns, so we could write it like this:

UPDATE tablename 
  SET jsoncolumn = json_extend(jsoncolumn, $2) 
  WHERE id = $1;

instead of this:

UPDATE tablename 
  SET data = (
    SELECT json_object_agg(key, value)::jsonb 
      FROM 
        ( SELECT * FROM jsonb_each( SELECT data FROM tablename WHERE id=$1 )
          UNION ALL
          SELECT * FROM jsonb_each( $2 ) 
        ) x1
  ) WHERE id=$1;

pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: Storing Video's or vedio file in DB.
Next
From: Albe Laurenz
Date:
Subject: Re: Storing Video's or vedio file in DB.