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
|
@ -40,7 +40,7 @@ module DB
|
|||
end
|
||||
end
|
||||
|
||||
# Performs the `query` discarding any response
|
||||
# Performs the `query` and returns an `ExecResult`
|
||||
def exec(query, *args)
|
||||
prepare(query).exec(*args)
|
||||
end
|
||||
|
|
|
@ -27,18 +27,18 @@ module DB
|
|||
|
||||
# See `QueryMethods#exec`
|
||||
def exec
|
||||
perform_exec_and_release(Slice(Any).new(0)) # no overload matches ... with types Slice(NoReturn)
|
||||
perform_exec_and_release(Slice(Any).new(0))
|
||||
end
|
||||
|
||||
# See `QueryMethods#exec`
|
||||
def exec(args : Enumerable(Any))
|
||||
perform_exec_and_release(args.to_a.to_unsafe.to_slice(args.size))
|
||||
def exec(args : Array)
|
||||
perform_exec_and_release(args)
|
||||
end
|
||||
|
||||
# See `QueryMethods#exec`
|
||||
def exec(*args)
|
||||
# TODO better way to do it
|
||||
perform_exec_and_release(args.to_a.to_unsafe.to_slice(args.size))
|
||||
perform_exec_and_release(args)
|
||||
end
|
||||
|
||||
# See `QueryMethods#scalar`
|
||||
|
@ -96,13 +96,13 @@ module DB
|
|||
end
|
||||
end
|
||||
|
||||
private def perform_exec_and_release(args : Slice(Any)) : ExecResult
|
||||
private def perform_exec_and_release(args : Enumerable) : ExecResult
|
||||
perform_exec(args).tap do
|
||||
release_connection
|
||||
end
|
||||
end
|
||||
|
||||
protected abstract def perform_query(args : Enumerable) : ResultSet
|
||||
protected abstract def perform_exec(args : Slice(Any)) : ExecResult
|
||||
protected abstract def perform_exec(args : Enumerable) : ExecResult
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue