diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-10-28 17:39:27 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-10-28 17:39:27 -0600 |
commit | e13ac306a09611c2d7f7e3ca813e8409d7dfc834 (patch) | |
tree | 79d4a93e72d7cff844335471dfdfd7c5997ade60 /activerecord/lib | |
parent | 79437642d537f24a36d9e649713941eebfff35c2 (diff) | |
download | rails-e13ac306a09611c2d7f7e3ca813e8409d7dfc834.tar.gz rails-e13ac306a09611c2d7f7e3ca813e8409d7dfc834.tar.bz2 rails-e13ac306a09611c2d7f7e3ca813e8409d7dfc834.zip |
Implement hash equality on column
The query cache uses bind values as hash keys. The current
implementation relies on reference equality for hash equality. This is
brittle, and can easily break in the future.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/column.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb index cdbcca3728..01f06af348 100644 --- a/activerecord/lib/active_record/connection_adapters/column.rb +++ b/activerecord/lib/active_record/connection_adapters/column.rb @@ -64,6 +64,11 @@ module ActiveRecord other.sql_type == sql_type && other.null == null end + alias :eql? :== + + def hash + [self.class, name, default, cast_type, sql_type, null].hash + end end end # :startdoc: |