add statement cache in connection.

hide methods from api
This commit is contained in:
Brian J. Cardiff 2016-02-03 18:46:37 -03:00
parent 562d5076bf
commit fa111fd698
5 changed files with 34 additions and 6 deletions

View file

@ -21,7 +21,7 @@ class DummyDriver < DB::Driver
@@connections.try &.clear
end
def prepare(query)
def build_statement(query)
DummyStatement.new(self, query)
end
@ -30,6 +30,7 @@ class DummyDriver < DB::Driver
end
protected def do_close
super
end
end

View file

@ -80,4 +80,15 @@ describe DB::Statement do
stmt.closed?.should be_false
end
end
it "connection should cache statements by query" do
with_dummy do |db|
rs = db.query "1, ?", 2
stmt = rs.statement
rs.close
rs = db.query "1, ?", 4
rs.statement.should be(stmt)
end
end
end