This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

[dm-more] Updated to use :required instead of :nullable for Property …

…declarations

[#935]
  • Loading branch information...
dkubb committed Nov 11, 2009
1 parent 875692d commit efa9d03b0673cd28f830387b3ebc82af5bf4a384
@@ -1,7 +1,7 @@
migration 2, :add_dob_to_people do
up do
modify_table :people do
- add_column :dob, DateTime, :nullable? => true
+ add_column :dob, DateTime, :allow_nil => true
end
end
@@ -21,7 +21,7 @@
migration 2, :add_dob_to_people do
up do
modify_table :people do
- add_column :dob, DateTime, :nullable? => true
+ add_column :dob, DateTime, :allow_nil => true
end
end
@@ -64,8 +64,14 @@ def to_sql
def build_type(type_class)
schema = { :name => @name, :quote_column_name => quoted_name }.merge(@opts)
- unless schema.key?(:nullable)
- schema[:nullable] = !schema[:not_null]
+ [ :nullable, :nullable? ].each do |option|
+ next if (value = schema.delete(option)).nil?
+ warn "#{option.inspect} is deprecated, use :allow_nil instead"
+ schema[:allow_nil] = value unless schema.key?(:allow_nil)
+ end
+
+ unless schema.key?(:allow_nil)
+ schema[:allow_nil] = !schema[:not_null]
end
schema[:length] ||= schema.delete(:size) if schema.key?(:size)
@@ -19,7 +19,7 @@ def repository(*args)
before do
@creator = DataMapper::Migration::TableCreator.new(repository(adapter).adapter, :people) do
column :id, DataMapper::Types::Serial
- column :name, 'VARCHAR(50)', :nullable => false
+ column :name, 'VARCHAR(50)', :allow_nil => false
column :long_string, String, :size => 200
end
end
@@ -58,7 +58,7 @@ def repository(*args)
col.instance_eval("@type").should include("200")
end
- it "should generate a NOT NULL column when :nullable is false" do
+ it "should generate a NOT NULL column when :allow_nil is false" do
@creator.instance_eval("@columns")[1].type.should match(/NOT NULL/)
end

0 comments on commit efa9d03

Please sign in to comment.