title: CQL - How to set Neo4j node property using a dynamic key in cypher?
body: <p>I'm trying to fix up incorrect data in my Neo4j database, and I'd like to have just a cypher to do the updating rather than transferring millions of rows to a custom application and back.</p>
  
  <p>I've created a Read query that's using dynamic keys to search through every property on all nodes of a labels I specify for various types of issues - in this case, an incorrectly serialized string. The issue I'm running into is that while the Read query using dynamic keys works great:</p>
  
  <pre><code>MATCH (n:xLabelNamex) 
  WITH 
      n, 
      [x IN keys(n) 
          WHERE n[x] STARTS WITH "\"" 
          AND n[x] ENDS WITH "\""
      ] AS doesMatch 
  WHERE size(doesMatch) &gt; 0 
  UNWIND doesMatch AS label 
      MATCH (m:xLabelNamex) 
      WHERE id(n)=id(m)
      RETURN SUBSTRING(m[label], 1, SIZE(m[label]) - 2)
  </code></pre>
  
  <p>But if I leave everything the same, and change the last line from</p>
  
  <pre><code>RETURN SUBSTRING(m[label], 1, SIZE(m[label]) - 2)
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>SET m[label] = SUBSTRING(m[label], 1, length(m[label]) - 2)
  </code></pre>
  
  <p>Results in the error:</p>
  
  <pre><code>Invalid input '[': expected an identifier character, node labels, a property map, whitespace, a relationship pattern, '(', '.', '=' or "+=" (line 12, column 10 (offset: 255))
  "    SET m[label] = SUBSTRING(m[label], 1, SIZE(m[label]) - 2)"
            ^
  </code></pre>
  
  <p>Is there a way to do this, or am I going down the wrong road here?</p>
  
  <p><em>Looking at the discussions on Github, I see that the addition of the reading of nodes using dynamic keys was added a little over a year ago, but it looks like they made it specifically targeted towards Read only. I started digging through Neo's source, but it's a behemoth. Any help would be appreciated.</em></p>