diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2014-12-04 14:10:14 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2014-12-04 14:10:14 -0700 |
commit | 6c9ed6dbc62450cdb87559afd15798305e069146 (patch) | |
tree | 557f511fe5b6b264763621d237f99c59d2662f49 /activerecord/lib | |
parent | da13b9aedccf437df933eb8620c0029b6a502aa1 (diff) | |
parent | c0609dd0f0f0de604ac1ffeffdf5e3e0e7356b35 (diff) | |
download | rails-6c9ed6dbc62450cdb87559afd15798305e069146.tar.gz rails-6c9ed6dbc62450cdb87559afd15798305e069146.tar.bz2 rails-6c9ed6dbc62450cdb87559afd15798305e069146.zip |
Merge pull request #17916 from mrgilman/deprecate-class-handler
Deprecate `Class` handler in `PredicateBuilder`
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index eb21d01465..67e646bf18 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -35,7 +35,7 @@ module ActiveRecord # PriceEstimate.where(estimate_of: treasure) if klass && reflection = klass._reflect_on_association(column) if reflection.polymorphic? && base_class = polymorphic_base_class_from_value(value) - queries << self.class.build(table[reflection.foreign_type], base_class) + queries << self.class.build(table[reflection.foreign_type], base_class.name) end column = reflection.foreign_key @@ -84,8 +84,7 @@ module ActiveRecord end register_handler(BasicObject, ->(attribute, value) { attribute.eq(value) }) - # FIXME: I think we need to deprecate this behavior - register_handler(Class, ->(attribute, value) { attribute.eq(value.name) }) + register_handler(Class, ->(attribute, value) { deprecate_class_handler; attribute.eq(value.name) }) register_handler(Base, ->(attribute, value) { attribute.eq(value.id) }) register_handler(Range, ->(attribute, value) { attribute.between(value) }) register_handler(Relation, RelationHandler.new) @@ -100,6 +99,13 @@ module ActiveRecord end private_class_method :handler_for + def self.deprecate_class_handler + ActiveSupport::Deprecation.warn(<<-MSG.squish) + Passing a class as a value in an Active Record query is deprecated and + will be removed. Pass a string instead. + MSG + end + protected attr_reader :klass, :table |