title: node-mysql use default if null on insert
body: <p>I'm fairly new to mysql, and I'm trying to get up and running with it in node using <a href="https://github.com/felixge/node-mysql" rel="nofollow">node-mysql</a>. I have created a simple table like so:</p>
  
  <pre><code>CREATE TABLE myTable (
      id SERIAL,
      display BOOLEAN NOT NULL DEFAULT 1,
      active BOOLEAN NOT NULL DEFAULT 0
  ) DEFAULT CHARSET utf8 COLLATE utf8_bin;
  </code></pre>
  
  <p>I am inserting rows like so:</p>
  
  <pre><code>db.query('INSERT INTO myTable SET ?', {
      display: myObject.display,
      active: myObject.active
  }, callback);
  </code></pre>
  
  <p>As the docs say, node-mysql converts the object i'm passing in to key value pairs. This works great if <code>myObject.display</code> and <code>myObject.active</code> are both defined. If one or both aren't, node-mysql tries to insert <code>NULL</code> into the columns, which is not allowed. I intended for the default value to be used in this situation, but its throwing an error about the <code>NULL</code> value. So my question is: </p>
  
  <p>1) Is there some special syntax to use when creating a table that will use the default when a null value is given, or 2) Is there some elegant way to do this with node-mysql that doesn't involve a bunch of object parsing? </p>
  
  <p>Feel free to expand your answer if you see something else I could improve. My larger goal is to learn the best way to create a robust, safe, and concise mysql insert in node.</p>