JSON_SET isn't updating null JSON field in MySQL
<p>I have a nullable JSON MySQL 5.7 field which I am finding almost impossible to get working. </p>

<p>Example query: </p>

<p><code>UPDATE `json_test` SET `data` = JSON_SET(`data`, '$.a', 1)</code></p>

<p>If the field data is NULL already, it won't update.</p>

<p>If it's <code>{ "a" : 2 }</code>, then it'll update correctly to 1. I need it to set if not set already, which is what JSON_SET is supposed to do.</p>

<p>Any ideas what's happening?</p>