提交 f27a45af 编写于 作者: R Ryuta Kamizono

Remove unused explicit delegation to `klass` in `relation`

It is only used `primary_key` and `connection` in the internal, so it is
not needed to delegate others to `klass` explicitly.
This doesn't change public behavior because `relation` will delegate
missing method to `klass`.
上级 bdc2ba0e
......@@ -580,7 +580,7 @@ def to_sql
#
# User.where(name: 'Oscar').where_values_hash
# # => {name: "Oscar"}
def where_values_hash(relation_table_name = table_name)
def where_values_hash(relation_table_name = klass.table_name)
where_clause.to_h(relation_table_name)
end
......
......@@ -43,8 +43,7 @@ def inherited(child_class)
:to_sentence, :to_formatted_s, :as_json,
:shuffle, :split, :slice, :index, :rindex, to: :records
delegate :table_name, :quoted_table_name, :primary_key, :quoted_primary_key,
:connection, :columns_hash, to: :klass
delegate :primary_key, :connection, to: :klass
module ClassSpecificRelation # :nodoc:
extend ActiveSupport::Concern
......
......@@ -73,11 +73,6 @@ def test_tree_is_not_traversed
assert_equal({}, relation.where_values_hash)
end
def test_table_name_delegates_to_klass
relation = Relation.new(FakeKlass, :b, Post.predicate_builder)
assert_equal "posts", relation.table_name
end
def test_scope_for_create
relation = Relation.new(FakeKlass, :b, nil)
assert_equal({}, relation.scope_for_create)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册