Permalink
Browse files

Remove deprecated support to passing a class as a value in a query

  • Loading branch information...
rafaelfranca committed Dec 29, 2016
1 parent 931b4b4 commit b4664864c972463c7437ad983832d2582186e886
@@ -1,3 +1,7 @@
* Remove deprecated support to passing a class as a value in a query.
*Rafael Mendonça França*
* Raises `ActiveRecord::IrreversibleOrderError` when using `last` with an irreversible
order.
@@ -4,7 +4,6 @@ class PredicateBuilder # :nodoc:
require "active_record/relation/predicate_builder/association_query_handler"
require "active_record/relation/predicate_builder/base_handler"
require "active_record/relation/predicate_builder/basic_object_handler"
require "active_record/relation/predicate_builder/class_handler"
require "active_record/relation/predicate_builder/polymorphic_array_handler"
require "active_record/relation/predicate_builder/range_handler"
require "active_record/relation/predicate_builder/relation_handler"
@@ -16,7 +15,6 @@ def initialize(table)
@handlers = []
register_handler(BasicObject, BasicObjectHandler.new)
register_handler(Class, ClassHandler.new(self))
register_handler(Base, BaseHandler.new(self))
register_handler(Range, RangeHandler.new)
register_handler(RangeHandler::RangeWithBinds, RangeHandler.new)
@@ -1,29 +0,0 @@
module ActiveRecord
class PredicateBuilder
class ClassHandler # :nodoc:
def initialize(predicate_builder)
@predicate_builder = predicate_builder
end
def call(attribute, value)
print_deprecation_warning
predicate_builder.build(attribute, value.name)
end
# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
attr_reader :predicate_builder
private
def print_deprecation_warning
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
end
end
end
@@ -840,15 +840,6 @@ def test_find_with_list_of_ar
assert_equal author, authors.first
end
class Mary < Author; end
def test_find_by_classname
Author.create!(name: Mary.name)
assert_deprecated do
assert_equal 1, Author.where(name: Mary).size
end
end
def test_find_by_id_with_list_of_ar
author = Author.first
authors = Author.find_by_id([author])

0 comments on commit b466486

Please sign in to comment.