mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
make Connection#prepared_statements? readonly
This commit is contained in:
parent
d55b088216
commit
4721ecbf6b
4 changed files with 8 additions and 14 deletions
|
@ -111,21 +111,17 @@ describe DB::Database do
|
||||||
end
|
end
|
||||||
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|
|
with_dummy "dummy://localhost:1027?prepared_statements=false&initial_pool_size=1" do |db|
|
||||||
connection = DummyDriver::DummyConnection.connections.first
|
connection = DummyDriver::DummyConnection.connections.first
|
||||||
connection.prepared_statements?.should be_false
|
connection.prepared_statements?.should be_false
|
||||||
connection.prepared_statements = true
|
|
||||||
connection.prepared_statements?.should be_true
|
|
||||||
end
|
end
|
||||||
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|
|
with_dummy "dummy://localhost:1027?prepared_statements=true&initial_pool_size=1" do |db|
|
||||||
connection = DummyDriver::DummyConnection.connections.first
|
connection = DummyDriver::DummyConnection.connections.first
|
||||||
connection.prepared_statements?.should be_true
|
connection.prepared_statements?.should be_true
|
||||||
connection.prepared_statements = false
|
|
||||||
connection.prepared_statements?.should be_false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -212,8 +212,8 @@ def with_dummy(uri : String = "dummy://host?checkout_timeout=0.5")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_dummy_connection
|
def with_dummy_connection(options = "")
|
||||||
with_dummy do |db|
|
with_dummy("dummy://host?checkout_timeout=0.5&#{options}") do |db|
|
||||||
db.using_connection do |cnn|
|
db.using_connection do |cnn|
|
||||||
yield cnn.as(DummyDriver::DummyConnection)
|
yield cnn.as(DummyDriver::DummyConnection)
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe DB::Statement do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should build unprepared statements" do
|
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 = cnn.unprepared("the query")
|
||||||
prepared.should be_a(DB::Statement)
|
prepared.should be_a(DB::Statement)
|
||||||
prepared.as(DummyDriver::DummyStatement).prepared?.should be_false
|
prepared.as(DummyDriver::DummyStatement).prepared?.should be_false
|
||||||
|
@ -19,16 +19,14 @@ describe DB::Statement do
|
||||||
|
|
||||||
describe "prepared_statements flag" do
|
describe "prepared_statements flag" do
|
||||||
it "should build prepared statements if true" do
|
it "should build prepared statements if true" do
|
||||||
with_dummy_connection do |cnn|
|
with_dummy_connection("prepared_statements=true") do |cnn|
|
||||||
cnn.prepared_statements = true
|
|
||||||
stmt = cnn.query("the query").statement
|
stmt = cnn.query("the query").statement
|
||||||
stmt.as(DummyDriver::DummyStatement).prepared?.should be_true
|
stmt.as(DummyDriver::DummyStatement).prepared?.should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should build unprepared statements if false" do
|
it "should build unprepared statements if false" do
|
||||||
with_dummy_connection do |cnn|
|
with_dummy_connection("prepared_statements=false") do |cnn|
|
||||||
cnn.prepared_statements = false
|
|
||||||
stmt = cnn.query("the query").statement
|
stmt = cnn.query("the query").statement
|
||||||
stmt.as(DummyDriver::DummyStatement).prepared?.should be_false
|
stmt.as(DummyDriver::DummyStatement).prepared?.should be_false
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ module DB
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
getter database
|
getter database
|
||||||
@statements_cache = StringKeyCache(Statement).new
|
@statements_cache = StringKeyCache(Statement).new
|
||||||
property? prepared_statements : Bool
|
getter? prepared_statements : Bool
|
||||||
|
|
||||||
def initialize(@database : Database)
|
def initialize(@database : Database)
|
||||||
@prepared_statements = @database.prepared_statements?
|
@prepared_statements = @database.prepared_statements?
|
||||||
|
|
Loading…
Reference in a new issue