title: postgres upsert json props
body: <p>I'm not sure if this is possible or not, but I'm trying to get into the nitty gritty of what I can do in postgres 9.6.1 and this seems like maybe its possible.  So given this table:</p>
  
  <pre><code>DROP TABLE IF EXISTS live_data;
  CREATE TABLE live_data (
  rec_id TEXT,
  control_data JSONB
  );
  CREATE UNIQUE INDEX rec_id_idx ON live_data (rec_id);
  </code></pre>
  
  <p>I want to be able to upsert individual props on the control_data json without having to upsert a whole new json string.</p>
  
  <p>With no rows in that table yet I tried this:</p>
  
  <pre><code>INSERT INTO live_data(rec_id, control_data) VALUES ('1', '{"set":{"some_prop": 99}}')
  ON CONFLICT (rec_id) DO UPDATE SET control_data-&gt;'set'-&gt;'some_prop' = 99;
  </code></pre>
  
  <p>FWIW I get this error on that query : </p>
  
  <pre><code>syntax error at or near "-&gt;"
  </code></pre>
  
  <p>Am I writing that query wrong and/or is what I want to do just not currently possible?</p>