From ec012e446ad5a502ce5fcf5139a3ed7ee9e220ba Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Tue, 28 Oct 2014 17:52:58 -0600 Subject: Add mysql and pg specific attributes to Column#== and hash --- .../connection_adapters/abstract_mysql_adapter.rb | 11 +++++++++++ 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 -- cgit v1.2.3