title: How do I modify a single property value inside the PostgreSQL JSONB datatype?
body: <p>How do I modify a single field inside the PostgreSQL JSONB datatype?</p>
  
  <p>Let's say I have a table called animal like this:</p>
  
  <pre><code>id       info
  ------------------------------------------------------------
  49493   {"habit1":"fly","habit2":"dive","location":"SONOMA NARITE"}
  </code></pre>
  
  <p>I'd like to simply change value(say, to upper case or lower case the text) of the location property. so the result, after UPDATE is</p>
  
  <pre><code>    id       info
  ------------------------------------------------------------
  49493   {"habit1":"fly","habit2":"dive","location":"sonoma narite"}
  </code></pre>
  
  <p>I tried this below and it does not work</p>
  
  <pre><code>update animal set info=jsonb_set(info, '{location}', LOWER(info-&gt;&gt;'location'), true) where id='49493';
  ----------------------------------
  ERROR:  function jsonb_set(jsonb, unknown, text, boolean) does not exist
  LINE 7: update animal set info=jsonb_set(info, '{con...
                                             ^
  HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
  ********** Error **********
  
  ERROR: function jsonb_set(jsonb, unknown, text, boolean) does not exist
  </code></pre>
  
  <p>if I simply know what the updated value would be then I can use just use this:</p>
  
  <pre><code>update animal set info=jsonb_set(info, '{location}', '"sonoma narite"', true) where id='49493';
  </code></pre>
  
  <p>However, if the text value is unknown and we just want to do some simply operation such as append, prepend, upper/lower case, I can't simply find an answer to it.</p>
  
  <p>I was surprised by the fact that jsonb set function does not offer such a trivial operation that only try to update the case of a text property inside a jsonb.</p>
  
  <p>Can someone help?</p>