aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/column.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-06-17 15:39:13 -0600
committerSean Griffin <sean@thoughtbot.com>2014-06-17 16:02:53 -0600
commit4d3e88fc757a1b6f6c468418af01dca677e41edf (patch)
tree82e1d7dc1267da9f65cdd9915459a508324e4bb3 /activerecord/lib/active_record/connection_adapters/column.rb
parent9f86780226c86fae30d59d04bd53449b8c7a1ad8 (diff)
downloadrails-4d3e88fc757a1b6f6c468418af01dca677e41edf.tar.gz
rails-4d3e88fc757a1b6f6c468418af01dca677e41edf.tar.bz2
rails-4d3e88fc757a1b6f6c468418af01dca677e41edf.zip
Don't type cast the default on the column
If we want to have type decorators mess with the attribute, but not the column, we need to stop type casting on the column. Where possible, we changed the tests to test the value of `column_defaults`, which is public API. `Column#default` is not.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/column.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/column.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb
index d629fca911..8be4678ace 100644
--- a/activerecord/lib/active_record/connection_adapters/column.rb
+++ b/activerecord/lib/active_record/connection_adapters/column.rb
@@ -13,7 +13,7 @@ module ActiveRecord
ISO_DATETIME = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/
end
- attr_reader :name, :cast_type, :null, :sql_type, :default_function
+ attr_reader :name, :cast_type, :null, :sql_type, :default, :default_function
delegate :type, :precision, :scale, :limit, :klass, :accessor,
:text?, :number?, :binary?, :changed?,
@@ -35,7 +35,7 @@ module ActiveRecord
@cast_type = cast_type
@sql_type = sql_type
@null = null
- @original_default = default
+ @default = default
@default_function = nil
end
@@ -51,13 +51,8 @@ module ActiveRecord
Base.human_attribute_name(@name)
end
- def default
- @default ||= type_cast_from_database(@original_default)
- end
-
def with_type(type)
dup.tap do |clone|
- clone.instance_variable_set('@default', nil)
clone.instance_variable_set('@cast_type', type)
end
end