diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-10-28 17:52:58 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-10-28 17:54:03 -0600 |
commit | ec012e446ad5a502ce5fcf5139a3ed7ee9e220ba (patch) | |
tree | cadfd477c3e4505aab1ce6151d96a79708b6193e /activerecord | |
parent | cd45306dbdf229ada6783c36cbd9cc18da26954a (diff) | |
download | rails-ec012e446ad5a502ce5fcf5139a3ed7ee9e220ba.tar.gz rails-ec012e446ad5a502ce5fcf5139a3ed7ee9e220ba.tar.bz2 rails-ec012e446ad5a502ce5fcf5139a3ed7ee9e220ba.zip |
Add mysql and pg specific attributes to Column#== and hash
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 11 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/column.rb | 11 |
2 files changed, 20 insertions, 2 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 e4cfe843a8..c5dd93ee89 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -91,6 +91,13 @@ module ActiveRecord collation && !collation.match(/_ci$/) end + def ==(other) + super && + collation == other.collation && + strict == other.strict && + extra == other.extra + end + private # MySQL misreports NOT NULL column default when none is given. @@ -109,6 +116,10 @@ module ActiveRecord raise ArgumentError, "#{type} columns cannot have a default value: #{default.inspect}" end end + + def attributes_for_hash + super + [collation, strict, extra] + end end ## diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb index 01f06af348..dd303c73d5 100644 --- a/activerecord/lib/active_record/connection_adapters/column.rb +++ b/activerecord/lib/active_record/connection_adapters/column.rb @@ -62,12 +62,19 @@ module ActiveRecord other.default == default && other.cast_type == cast_type && other.sql_type == sql_type && - other.null == null + other.null == null && + other.default_function == default_function end alias :eql? :== def hash - [self.class, name, default, cast_type, sql_type, null].hash + attributes_for_hash.hash + end + + private + + def attributes_for_hash + [self.class, name, default, cast_type, sql_type, null, default_function] end end end |