diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-31 14:47:21 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 14:25:46 -0800 |
commit | a7c2f6be3050b035865a48accb102568c961c1bf (patch) | |
tree | 1c1755f3997dfbac0d80dac0114a53dad9adb67e | |
parent | 6d5e3b86d581c109ad60fe771de0ac852f1af259 (diff) | |
download | rails-a7c2f6be3050b035865a48accb102568c961c1bf.tar.gz rails-a7c2f6be3050b035865a48accb102568c961c1bf.tar.bz2 rails-a7c2f6be3050b035865a48accb102568c961c1bf.zip |
coders can be assigned to columns
-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 |