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:
Brian J. Cardiff 2016-12-02 22:09:27 -03:00
parent fe0ed55ef9
commit 9ef9d19d1d
6 changed files with 80 additions and 3 deletions

View file

@ -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)