title: NULL defaults to empty string in mysql?
body: <p>I have a strange situation with a field that doesn't allow NULL values. If I insert a row, the field defaults to the empty string, even when mysql claims that the default is NULL.</p>
  
  <pre><code>mysql&gt; describe user;
  +---------------------------+------------------+------+-----+---------+----------------+
  | Field                     | Type             | Null | Key | Default | Extra          |
  +---------------------------+------------------+------+-----+---------+----------------+
  | id                        | int(30)          | NO   | PRI | NULL    | auto_increment |
  | username                  | varchar(45)      | NO   | UNI | NULL    |                |
  | city                      | varchar(45)      | NO   |     | NULL    |                |
  +---------------------------+------------------+------+-----+---------+----------------+
  
  mysql&gt; show triggers;
  Empty set (0.00 sec)
  
  mysql&gt; insert into user (username) values ('just_testing');
  Query OK, 1 row affected, 17 warnings (0.01 sec)
  </code></pre>
  
  <p>This is the point where I go <em>WHAT?!</em> - city should default to NULL which isn't allowed, but look here:</p>
  
  <pre><code>mysql&gt; select username, city from user where username = 'just_testing' and city is null;
  Empty set (0.00 sec)
  
  mysql&gt; select username, city from user where username = 'just_testing' and city='';
  +--------------+------+
  | username     | city |
  +--------------+------+
  | just_testing |      |
  +--------------+------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>Mysql has decided to use the empty string as default even though it isn't so and there isn't any triggers.</p>
  
  <p>And further:</p>
  
  <pre><code>mysql&gt; insert into user (username, city) values ('just_testing3', NULL);
  ERROR 1048 (23000): Column 'city' cannot be null
  </code></pre>
  
  <p>What am I overlooking? How does the city column default to ''?</p>