mirror of
https://github.com/github/rails.git
synced 2026-02-16 09:05:14 -05:00
Cache columns for has_and_belongs_to_many associations
This avoids repeatedly calling SHOW COLUMNS when the association is queried [#1738 state:committed]
This commit is contained in:
committed by
Michael Koziarski
parent
fe013ce934
commit
3ee4e00918
@@ -775,4 +775,15 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_caching_of_columns
|
||||
david = Developer.find(1)
|
||||
# clear cache possibly created by other tests
|
||||
david.projects.reset_column_information
|
||||
assert_queries(1) { david.projects.columns; david.projects.columns }
|
||||
# and again to verify that reset_column_information clears the cache correctly
|
||||
david.projects.reset_column_information
|
||||
assert_queries(1) { david.projects.columns; david.projects.columns }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user