Cannot clear object cache #25

Open
jgebal opened this Issue Feb 1, 2012 · 1 comment

Projects

None yet

2 participants

@jgebal
Contributor
jgebal commented Feb 1, 2012

There is no public method to clear object cache for schema.
I've found method Schema.reset_instance_variables but it is private.
We need to be able to tell ruby that object definitions were changed by Spec file or any other file.
How can we do that?
Can you give me a clue or make the reset_instance_variables public?

When performing a switch on synonyms from Real tables to test tables and back, the cache is not refreshed.
What i would like to have is ability to reset cache on after(:all).
When we run multiple tests sets, some tests are working on real tables, some other tests work on test tables.

Steps to reproduce problem:

require File.expand_path(File.dirname(FILE) + '/spec_helper')

describe "Refresh Roaming Zone Set, so it represents all the Partners currently defined, not only those defined when the Roaming Zone set was created" do
before(:all) do
plsql.execute("CREATE TABLE AA( A INTEGER)")
plsql.execute("CREATE TABLE BB( A INTEGER)")
plsql.execute("CREATE SYNONYM TEST_SYN FOR AA")
plsql.aa.insert(:a => 1)

puts plsql.select(:first, "select count(1) FROM TEST_SYN").values[0]
puts plsql.TEST_SYN.count
plsql.execute("CREATE OR REPLACE SYNONYM TEST_SYN FOR BB");

end

it "should properly switch object references" do
plsql.select(:first, "select count(1) FROM TEST_SYN").values[0]
.should == plsql.TEST_SYN.count
end

after(:all) do
plsql.execute("DROP TABLE AA")
plsql.execute("DROP TABLE BB")
plsql.execute("DROP SYNONYM TEST_SYN")
end
end

@rsim
Owner
rsim commented Apr 16, 2012

You can reestablish connection to clear schema object cache - I migrated tests to RSpec 2 which has different semantics for top level before(:all) and after(:all) blocks and therefore moved connection creation to lower level before(:all) blocks where necessary.

But probably this method should be exposed publicly as well - just wondering if there is any other use case besides ruby-plsql own tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment