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
|
@ -17,6 +17,24 @@ describe DB::Statement do
|
|||
end
|
||||
end
|
||||
|
||||
describe "prepared_statements flag" do
|
||||
it "should build prepared statements if true" do
|
||||
with_dummy_connection do |cnn|
|
||||
cnn.prepared_statements = true
|
||||
stmt = cnn.query("the query").statement
|
||||
stmt.as(DummyDriver::DummyStatement).prepared?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
it "should build unprepared statements if false" do
|
||||
with_dummy_connection do |cnn|
|
||||
cnn.prepared_statements = false
|
||||
stmt = cnn.query("the query").statement
|
||||
stmt.as(DummyDriver::DummyStatement).prepared?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "should initialize positional params in query" do
|
||||
with_dummy_connection do |cnn|
|
||||
stmt = cnn.prepared("the query").as(DummyDriver::DummyStatement)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue