Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Dec 22, 2023
1 parent c511237 commit 189e334
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion activerecord/lib/active_record/relation/delegation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ def #{method}(...)
:to_sentence, :to_fs, :to_formatted_s, :as_json,
:shuffle, :split, :slice, :index, :rindex, to: :records

delegate :primary_key, :connection, :table_name, :transaction, :arel_table, :uncached, :sanitize_sql_like, to: :klass
delegate :primary_key, :connection, :table_name, :transaction, :arel_table, :uncached,
:sanitize_sql_like, :unscoped, to: :klass

# TODO: scoped delegate
[:find_signed, :find_signed!, :delete].each do |method|
module_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{method}(...)
scoping { klass.#{method}(...) }
end
RUBY
end

module ClassSpecificRelation # :nodoc:
extend ActiveSupport::Concern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,14 +828,14 @@ def test_caching_of_columns
# clear cache possibly created by other tests
Project.reset_column_information

assert_queries_count(include_schema: true) { david.projects.columns }
assert_no_queries { david.projects.columns }
assert_queries_count(include_schema: true) { Project.columns }
assert_no_queries { Project.columns }

## and again to verify that reset_column_information clears the cache correctly
Project.reset_column_information

assert_queries_count(include_schema: true) { david.projects.columns }
assert_no_queries { david.projects.columns }
assert_queries_count(include_schema: true) { Project.columns }
assert_no_queries { Project.columns }
end

def test_attributes_are_being_set_when_initialized_from_habtm_association_with_where_clause
Expand Down

0 comments on commit 189e334

Please sign in to comment.