mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
allow exec to receive any object arguments
This commit is contained in:
parent
d4b2046a65
commit
76e3a35d59
4 changed files with 34 additions and 12 deletions
|
@ -72,8 +72,8 @@ class FooDriver < DB::Driver
|
|||
GenericResultSet(Any).new(self, FooDriver.fake_row)
|
||||
end
|
||||
|
||||
protected def perform_exec(args : Slice(DB::Any)) : DB::ExecResult
|
||||
raise "Not implemented"
|
||||
protected def perform_exec(args : Enumerable) : DB::ExecResult
|
||||
DB::ExecResult.new 0, 0i64
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -114,8 +114,8 @@ class BarDriver < DB::Driver
|
|||
GenericResultSet(Any).new(self, BarDriver.fake_row)
|
||||
end
|
||||
|
||||
protected def perform_exec(args : Slice(DB::Any)) : DB::ExecResult
|
||||
raise "Not implemented"
|
||||
protected def perform_exec(args : Enumerable) : DB::ExecResult
|
||||
DB::ExecResult.new 0, 0i64
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -193,4 +193,26 @@ describe DB do
|
|||
db.query("query", [1, "string", BarValue.new(5)]).close
|
||||
end
|
||||
end
|
||||
|
||||
it "allow custom types to be used as arguments for exec" do
|
||||
DB.open("foo://host") do |db|
|
||||
FooDriver.fake_row = [1, "string"] of FooDriver::Any
|
||||
db.exec("query")
|
||||
db.exec("query", 1)
|
||||
db.exec("query", 1, "string")
|
||||
db.exec("query", Slice(UInt8).new(4))
|
||||
db.exec("query", 1, "string", FooValue.new(5))
|
||||
db.exec("query", [1, "string", FooValue.new(5)])
|
||||
end
|
||||
|
||||
DB.open("bar://host") do |db|
|
||||
BarDriver.fake_row = [1, "string"] of BarDriver::Any
|
||||
db.exec("query")
|
||||
db.exec("query", 1)
|
||||
db.exec("query", 1, "string")
|
||||
db.exec("query", Slice(UInt8).new(4))
|
||||
db.exec("query", 1, "string", BarValue.new(5))
|
||||
db.exec("query", [1, "string", BarValue.new(5)])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ class DummyDriver < DB::Driver
|
|||
DummyResultSet.new self, @query
|
||||
end
|
||||
|
||||
protected def perform_exec(args : Slice(DB::Any))
|
||||
protected def perform_exec(args : Enumerable)
|
||||
set_params args
|
||||
DB::ExecResult.new 0, 0_i64
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue