From 3ee4e009185173aab78f6503ee45e3ef4482874e Mon Sep 17 00:00:00 2001 From: lukeludwig Date: Fri, 16 Jan 2009 13:04:19 -0600 Subject: Cache columns for has_and_belongs_to_many associations This avoids repeatedly calling SHOW COLUMNS when the association is queried [#1738 state:committed] --- .../associations/has_and_belongs_to_many_associations_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 2f08e09d43..ee03d5d944 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -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 -- cgit v1.2.3