Statement#exec and #query require named argument for array values

This change allows to use an array as single argument for #exec and
 #query methods. Before it was shadowed by the *args splat overload.
This commit is contained in:
Johannes Müller 2019-09-05 17:37:11 +02:00
parent dcd0af5ce8
commit d0d89c1e13
No known key found for this signature in database
GPG key ID: F0F349637AC5087A
3 changed files with 27 additions and 7 deletions

View file

@ -43,10 +43,18 @@ describe DB::Statement do
end
end
it "should initialize positional params in query with array" do
it "accepts array as single argument" do
with_dummy_connection do |cnn|
stmt = cnn.prepared("the query").as(DummyDriver::DummyStatement)
stmt.query ["a", 1, nil]
stmt.params[0].should eq(["a", 1, nil])
end
end
it "should initialize positional params in query with array" do
with_dummy_connection do |cnn|
stmt = cnn.prepared("the query").as(DummyDriver::DummyStatement)
stmt.query args: ["a", 1, nil]
stmt.params[0].should eq("a")
stmt.params[1].should eq(1)
stmt.params[2].should eq(nil)
@ -63,10 +71,18 @@ describe DB::Statement do
end
end
it "should initialize positional params in exec with array" do
it "accepts array as single argument" do
with_dummy_connection do |cnn|
stmt = cnn.prepared("the query").as(DummyDriver::DummyStatement)
stmt.exec ["a", 1, nil]
stmt.params[0].should eq(["a", 1, nil])
end
end
it "should initialize positional params in exec with array" do
with_dummy_connection do |cnn|
stmt = cnn.prepared("the query").as(DummyDriver::DummyStatement)
stmt.exec args: ["a", 1, nil]
stmt.params[0].should eq("a")
stmt.params[1].should eq(1)
stmt.params[2].should eq(nil)