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

@ -97,7 +97,7 @@ class DummyDriver < DB::Driver
property params
def initialize(connection, @query : String, @prepared : Bool)
@params = Hash(Int32 | String, DB::Any).new
@params = Hash(Int32 | String, DB::Any | Array(DB::Any)).new
super(connection)
raise DB::Error.new(query) if query == "syntax error"
end
@ -126,6 +126,10 @@ class DummyDriver < DB::Driver
@params[index] = value
end
private def set_param(index, value : Array)
@params[index] = value.map(&.as(DB::Any))
end
private def set_param(index, value)
raise "not implemented for #{value.class}"
end