diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-06-17 15:39:13 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-06-17 16:02:53 -0600 |
commit | 4d3e88fc757a1b6f6c468418af01dca677e41edf (patch) | |
tree | 82e1d7dc1267da9f65cdd9915459a508324e4bb3 /activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | |
parent | 9f86780226c86fae30d59d04bd53449b8c7a1ad8 (diff) | |
download | rails-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/abstract_mysql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index a9b97d5919..3ef8878ad1 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -62,15 +62,14 @@ module ActiveRecord @extra = extra super(name, default, cast_type, sql_type, null) assert_valid_default(default) + extract_default end - def default - @default ||= if blob_or_text_column? - null || strict ? nil : '' - elsif missing_default_forged_as_empty_string?(@original_default) - nil - else - super + def extract_default + if blob_or_text_column? + @default = null || strict ? nil : '' + elsif missing_default_forged_as_empty_string?(@default) + @default = nil end end |