mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
add prepared_statements option to database
* use ?prepared_statements=true|false on connection string (default: true) * make inmutable state in database * make mutable state in connection * change Connection#build to use the current prepared_statements flag to build prepared or unprepared statements.
This commit is contained in:
parent
fe0ed55ef9
commit
9ef9d19d1d
6 changed files with 80 additions and 3 deletions
|
@ -97,4 +97,36 @@ describe DB::Database do
|
|||
DummyDriver::DummyConnection.connections.size.should eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "prepared_statements connection option" do
|
||||
it "defaults to true" do
|
||||
with_dummy "dummy://localhost:1027" do |db|
|
||||
db.prepared_statements?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
it "can be set to false" do
|
||||
with_dummy "dummy://localhost:1027?prepared_statements=false" do |db|
|
||||
db.prepared_statements?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
it "is copied to connections and can be changed (false)" do
|
||||
with_dummy "dummy://localhost:1027?prepared_statements=false&initial_pool_size=1" do |db|
|
||||
connection = DummyDriver::DummyConnection.connections.first
|
||||
connection.prepared_statements?.should be_false
|
||||
connection.prepared_statements = true
|
||||
connection.prepared_statements?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
it "is copied to connections and can be changed (true)" do
|
||||
with_dummy "dummy://localhost:1027?prepared_statements=true&initial_pool_size=1" do |db|
|
||||
connection = DummyDriver::DummyConnection.connections.first
|
||||
connection.prepared_statements?.should be_true
|
||||
connection.prepared_statements = false
|
||||
connection.prepared_statements?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue