diff --git a/spec/database_spec.cr b/spec/database_spec.cr index f20aac1..3915a02 100644 --- a/spec/database_spec.cr +++ b/spec/database_spec.cr @@ -111,21 +111,17 @@ describe DB::Database do end end - it "is copied to connections and can be changed (false)" do + it "is copied to connections (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 + it "is copied to connections (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 diff --git a/spec/dummy_driver.cr b/spec/dummy_driver.cr index d7e4cdd..426fe74 100644 --- a/spec/dummy_driver.cr +++ b/spec/dummy_driver.cr @@ -212,8 +212,8 @@ def with_dummy(uri : String = "dummy://host?checkout_timeout=0.5") end end -def with_dummy_connection - with_dummy do |db| +def with_dummy_connection(options = "") + with_dummy("dummy://host?checkout_timeout=0.5&#{options}") do |db| db.using_connection do |cnn| yield cnn.as(DummyDriver::DummyConnection) end diff --git a/spec/statement_spec.cr b/spec/statement_spec.cr index 0e410da..70c3385 100644 --- a/spec/statement_spec.cr +++ b/spec/statement_spec.cr @@ -10,7 +10,7 @@ describe DB::Statement do end it "should build unprepared statements" do - with_dummy_connection do |cnn| + with_dummy_connection("prepared_statements=false") do |cnn| prepared = cnn.unprepared("the query") prepared.should be_a(DB::Statement) prepared.as(DummyDriver::DummyStatement).prepared?.should be_false @@ -19,16 +19,14 @@ describe DB::Statement do describe "prepared_statements flag" do it "should build prepared statements if true" do - with_dummy_connection do |cnn| - cnn.prepared_statements = true + with_dummy_connection("prepared_statements=true") do |cnn| 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 + with_dummy_connection("prepared_statements=false") do |cnn| stmt = cnn.query("the query").statement stmt.as(DummyDriver::DummyStatement).prepared?.should be_false end diff --git a/src/db/connection.cr b/src/db/connection.cr index 74ac257..803ebd8 100644 --- a/src/db/connection.cr +++ b/src/db/connection.cr @@ -25,7 +25,7 @@ module DB # :nodoc: getter database @statements_cache = StringKeyCache(Statement).new - property? prepared_statements : Bool + getter? prepared_statements : Bool def initialize(@database : Database) @prepared_statements = @database.prepared_statements?