Re: ActiveRecord uses confusing defaults

Jeroen Houben
Fri, 08 Sep 2006 14:08:07 -0000

Jeroen Houben wrote:
> Rick Olson wrote:
>> On 9/8/06, Jeroen Houben
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
>>> now I would expect this to return nil
>>>
>>> s.street # => ''''
>>> I would expect this to return nil
>>>
>>> Is there a reason for this?
>>>

Here''s the info from MySql

mysql> show fields from submissions;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | int(11)      | NO   | PRI | NULL    | auto_increment |
| email        | varchar(255) | NO   |     |         |                |
| fname        | varchar(255) | NO   |     |         |                |
| lname        | varchar(255) | NO   |     |         |                |
| street       | varchar(255) | YES  |     | NULL    |                |
| postcode     | varchar(6)   | NO   |     |         |                |
| city         | varchar(255) | NO   |     |         |                |
| shirt_type   | varchar(255) | NO   |     | m       |                |
| shirt_size   | varchar(255) | NO   |     | l       |                |
| shirt_text   | text         | NO   |     |         |                |
| processed_at | datetime     | YES  |     | NULL    |                |
| approved_at  | datetime     | YES  |     | NULL    |                |
| created_at   | datetime     | NO   |     |         |                |
| updated_at   | datetime     | NO   |     |         |                |
| housenr      | int(11)      | NO   |     |         |                |
| housenr_ext  | varchar(255) | YES  |     | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+

So I''m pretty sure I''m never using "" as my defaults
yet a rake
db:schema:dump thinks that I am (see previous post)

Please not that I am not using the native mysql gem as that gave me even
more obscure problems on Win32.

Jeroen