From 702b1768c425e7187ef4c62beb1ed12ed7774d83 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 6 Jun 2018 19:20:13 +0900 Subject: Fix force equality checking not to break the serialized attribute with Array Context: https://github.com/rails/rails/commit/43ef00e5d7a55ad79bc840276d33cb70f1f5dde5#commitcomment-29256140 --- activerecord/lib/active_record/relation/predicate_builder.rb | 1 - activerecord/lib/active_record/type/serialized.rb | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 4a4ceca782..f734cd0ad8 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -48,7 +48,6 @@ module ActiveRecord end def build(attribute, value) - # FIXME: Deprecate this and provide a public API to force equality if table.type(attribute.name).force_equality?(value) bind = build_bind_attribute(attribute.name, value) attribute.eq(bind) diff --git a/activerecord/lib/active_record/type/serialized.rb b/activerecord/lib/active_record/type/serialized.rb index e882784691..0a2f6cb9fb 100644 --- a/activerecord/lib/active_record/type/serialized.rb +++ b/activerecord/lib/active_record/type/serialized.rb @@ -51,6 +51,10 @@ module ActiveRecord end end + def force_equality?(value) + coder.respond_to?(:object_class) && value.is_a?(coder.object_class) + end + private def default_value?(value) -- cgit v1.2.3