Skip to content
Browse files

Test that statement cache is cleared when limit is reached.

  • Loading branch information...
1 parent 2c9b36f commit cf746deb0a0353e04b4541a54477d2d6f39429dc @ebeigarts ebeigarts committed Sep 16, 2011
Showing with 18 additions and 1 deletion.
  1. +18 −1 spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
View
19 spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
@@ -668,8 +668,9 @@ class ::TestComment < ActiveRecord::Base
end if ENV['RAILS_GEM_VERSION'] >= '3.1'
- describe "with statements pool" do
+ describe "with statement pool" do
before(:all) do
+ ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(:statement_limit => 3))
@conn = ActiveRecord::Base.connection
schema_define do
drop_table :test_posts rescue nil
@@ -680,6 +681,10 @@ class ::TestPost < ActiveRecord::Base
@statements = @conn.instance_variable_get(:@statements)
end
+ before(:each) do
+ @conn.clear_cache!
+ end
+
after(:all) do
schema_define do
drop_table :test_posts
@@ -688,6 +693,18 @@ class ::TestPost < ActiveRecord::Base
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
end
+ it "should clear older cursors when statement limit is reached" do
+ pk = TestPost.columns.find { |c| c.primary }
+ sub = @conn.substitute_at(pk, 0)
+ binds = [[pk, 1]]
+
+ lambda {
+ 4.times do |i|
+ @conn.exec_query("SELECT * FROM test_posts WHERE #{i}=#{i} AND id = #{sub}", "SQL", binds)
+ end
+ }.should change(@statements, :length).by(+3)
+ end
+
it "should cache UPDATE statements with bind variables" do
lambda {
pk = TestPost.columns.find { |c| c.primary }

0 comments on commit cf746de

Please sign in to comment.
Something went wrong with that request. Please try again.