diff options
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 5 | ||||
-rw-r--r-- | activerecord/test/cases/column_definition_test.rb | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index e1a39feb07..e2582f7f15 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -17,7 +17,9 @@ module ActiveRecord end attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale - attr_accessor :primary + attr_accessor :primary, :coder + + alias :encoded? :coder # Instantiates a new column in the table. # @@ -37,6 +39,7 @@ module ActiveRecord @type = simplified_type(sql_type) @default = extract_default(default) @primary = nil + @coder = nil end # Returns +true+ if the column is either of type string or text. diff --git a/activerecord/test/cases/column_definition_test.rb b/activerecord/test/cases/column_definition_test.rb index f87f819812..a80deee93e 100644 --- a/activerecord/test/cases/column_definition_test.rb +++ b/activerecord/test/cases/column_definition_test.rb @@ -10,6 +10,20 @@ module ActiveRecord end end + def test_can_set_coder + column = Column.new("title", nil, "varchar(20)") + column.coder = YAML + assert_equal YAML, column.coder + end + + def test_encoded? + column = Column.new("title", nil, "varchar(20)") + assert !column.encoded? + + column.coder = YAML + assert column.encoded? + end + # Avoid column definitions in create table statements like: # `title` varchar(255) DEFAULT NULL def test_should_not_include_default_clause_when_default_is_null |