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-12 20:58:53 +02:00
parent d0d89c1e13
commit b2fbc2f0f0
No known key found for this signature in database
GPG key ID: F0F349637AC5087A
3 changed files with 263 additions and 12 deletions

View file

@ -227,14 +227,14 @@ describe DB do
db.query "query", 1, "string" { }
db.query("query", Bytes.new(4)) { }
db.query("query", 1, "string", FooValue.new(5)) { }
db.query "query", [1, "string", FooValue.new(5)] { }
db.query "query", args: [1, "string", FooValue.new(5)] { }
db.query("query").close
db.query("query", 1).close
db.query("query", 1, "string").close
db.query("query", Bytes.new(4)).close
db.query("query", 1, "string", FooValue.new(5)).close
db.query("query", [1, "string", FooValue.new(5)]).close
db.query("query", args: [1, "string", FooValue.new(5)]).close
end
DB.open("bar://host") do |db|
@ -244,14 +244,14 @@ describe DB do
db.query "query", 1, "string" { }
db.query("query", Bytes.new(4)) { }
db.query("query", 1, "string", BarValue.new(5)) { }
db.query "query", [1, "string", BarValue.new(5)] { }
db.query "query", args: [1, "string", BarValue.new(5)] { }
db.query("query").close
db.query("query", 1).close
db.query("query", 1, "string").close
db.query("query", Bytes.new(4)).close
db.query("query", 1, "string", BarValue.new(5)).close
db.query("query", [1, "string", BarValue.new(5)]).close
db.query("query", args: [1, "string", BarValue.new(5)]).close
end
end
@ -263,7 +263,7 @@ describe DB do
db.exec("query", 1, "string")
db.exec("query", Bytes.new(4))
db.exec("query", 1, "string", FooValue.new(5))
db.exec("query", [1, "string", FooValue.new(5)])
db.exec("query", args: [1, "string", FooValue.new(5)])
end
DB.open("bar://host") do |db|
@ -273,20 +273,20 @@ describe DB do
db.exec("query", 1, "string")
db.exec("query", Bytes.new(4))
db.exec("query", 1, "string", BarValue.new(5))
db.exec("query", [1, "string", BarValue.new(5)])
db.exec("query", args: [1, "string", BarValue.new(5)])
end
end
it "Foo and Bar drivers should not implement each other params" do
DB.open("foo://host") do |db|
expect_raises Exception, "FooDriver::FooStatement does not support BarValue params" do
db.exec("query", [BarValue.new(5)])
db.exec("query", args: [BarValue.new(5)])
end
end
DB.open("bar://host") do |db|
expect_raises Exception, "BarDriver::BarStatement does not support FooValue params" do
db.exec("query", [FooValue.new(5)])
db.exec("query", args: [FooValue.new(5)])
end
end
end