mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
assert connection is closed after db is used.
tidy up close methods
This commit is contained in:
parent
3598dddb65
commit
6a5b2a8758
5 changed files with 58 additions and 28 deletions
|
@ -21,20 +21,20 @@ module DB
|
|||
|
||||
# Closes this connection.
|
||||
def close
|
||||
raise "Connection already closed" if @closed # TODO make it no fail if closed
|
||||
return if @closed
|
||||
@closed = true
|
||||
perform_close
|
||||
end
|
||||
|
||||
# Returns `true` if this statement is closed. See `#close`.
|
||||
# Returns `true` if this connection is closed. See `#close`.
|
||||
def closed?
|
||||
@closed
|
||||
end
|
||||
|
||||
# # :nodoc:
|
||||
# def finalize
|
||||
# close unless closed?
|
||||
# end
|
||||
# :nodoc:
|
||||
def finalize
|
||||
close unless closed?
|
||||
end
|
||||
|
||||
# Returns an `Statement` with the prepared `query`
|
||||
abstract def prepare(query) : Statement
|
||||
|
|
|
@ -16,6 +16,7 @@ module DB
|
|||
@closed = false
|
||||
end
|
||||
|
||||
|
||||
# See `QueryMethods#exec`
|
||||
def exec
|
||||
perform_exec(Slice(Any).new(0)) # no overload matches ... with types Slice(NoReturn)
|
||||
|
@ -83,7 +84,7 @@ module DB
|
|||
|
||||
# Closes this statement.
|
||||
def close
|
||||
return if @closed # make it work if closed
|
||||
return if @closed
|
||||
@closed = true
|
||||
do_close
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue