title: Bulk inserting rows on duplicate key update into mysql through Node.js while also executing a mysql function
body: <p>I'm trying to issue a bulk row insert using node-mysql, and normally this is not an issue, but I need to execute a MySQL function on one of the columns.</p>
  
  <p>Normally I would execute something like this and be fine:</p>
  
  <pre><code>INSERT INTO table1 (super_repo, reference, path, sub_repo, commit)
  VALUES ?
  ON DUPLICATE KEY
   UPDATE sub_repo = VALUES(sub_repo), commit = VALUES(commit)
  </code></pre>
  
  <p>But, in this case, the 'commit' column is a BINARY field, so I need to execute the MySQL<a href="https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_unhex" rel="nofollow noreferrer">UNHEX()</a> on the commit string so it stores it properly in the database.</p>
  
  <p>Passing the module this SQL throws the Error: ER_PARSE_ERROR</p>
  
  <pre><code>INSERT INTO table1 (super_repo, reference, path, sub_repo, commit)
  VALUES (?, ?, ?, ?, UNHEX(?))
  ON DUPLICATE KEY
   UPDATE sub_repo = VALUES(sub_repo), commit = VALUES(commit)
  </code></pre>
  
  <p>I'm guessing this doesn't work as it doesn't tell the MySql module that I am trying to insert multiple rows.
  Is there a way I can get this to work? Or alternatively, is there a node equivalent of doing the MySQL UNHEX() so that I can use the first SQL query above?</p>
  
  <p>I'm doing this as I'm taking a 40 character SHA1 hash and condensing it into a 20 char BINARY field in MySQL.</p>