
Incorrect String property :default behavior
Reported by Foo Bar | March 21st, 2011 @ 09:45 AM
require 'rubygems'
require 'dm-core'
require 'dm-types'
require 'dm-validations'
require 'dm-timestamps'
require 'dm-migrations'
DataMapper.setup(:default, "mysql://")
class Test
include DataMapper::Resource
property :id, Serial
property :error, String, :length => 140, :default => :null
end
DataMapper.auto_upgrade!
gives out:
CREATE TABLE IF NOT EXISTS `tests` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`error` varchar(140) DEFAULT 'null',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Why default 'null' ? not NULL
Comments and changes to this ticket
-
Piotr Solnica (solnic) March 21st, 2011 @ 10:49 AM
- State changed from new to not-applicable
Use :default => nil
-
Dan Kubb (dkubb) March 21st, 2011 @ 04:17 PM
If you don't specify anything the default :default value is nil.
I tend to encourage people to only specify options that are different from the defaults, but if you like to be explicit then solnic's suggestion is best.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »