Ticket #7932: method_missing_for_table_definitions_by_extend.diff
| File method_missing_for_table_definitions_by_extend.diff, 1.9 kB (added by norbert, 1 year ago) |
|---|
-
activerecord/test/migration_test.rb
old new 93 93 Person.connection.drop_table :testings rescue nil 94 94 end 95 95 96 def test_create_table_with_method_missing 97 Person.connection.create_table :testings do |t| 98 t.one :string 99 t.two :integer, :default => 2 100 end 101 102 columns = Person.connection.columns(:testings) 103 104 assert_equal %w(id one two), columns.map { |c| c.name }.sort 105 assert_equal 2, columns.find { |c| c.name == "two" }.default 106 ensure 107 Person.connection.drop_table :testings rescue nil 108 end 109 96 110 def test_create_table_with_not_null_column 97 111 assert_nothing_raised do 98 112 Person.connection.create_table :testings do |t| -
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
old new 90 90 def create_table(name, options = {}) 91 91 table_definition = TableDefinition.new(self) 92 92 table_definition.primary_key(options[:primary_key] || "id") unless options[:id] == false 93 extend_table_definition! table_definition 93 94 94 95 yield table_definition 95 96 … … 298 299 def options_include_default?(options) 299 300 options.include?(:default) && !(options[:null] == false && options[:default].nil?) 300 301 end 302 303 def extend_table_definition!(table_definition) 304 class << table_definition 305 def method_missing(name, *args) 306 column(name, *args) 307 end 308 end 309 end 301 310 end 302 311 end 303 312 end