mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
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:
parent
d0d89c1e13
commit
b2fbc2f0f0
3 changed files with 263 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue