mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
add statement cache in connection.
hide methods from api
This commit is contained in:
parent
562d5076bf
commit
fa111fd698
5 changed files with 34 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue