Add workaround for crystal-lang/crystal#9483 (#160)

* Add workaround for crystal-lang/crystal#9483

* Update src/db/begin_transaction.cr

Co-authored-by: Johannes Müller <straightshoota@gmail.com>

Co-authored-by: Johannes Müller <straightshoota@gmail.com>
This commit is contained in:
Brian J. Cardiff 2022-01-22 15:06:16 -03:00 committed by GitHub
parent d829b07b01
commit 27ade07359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,7 +13,9 @@ module DB
# can be called explicitly.
# Returns the value of the block.
def transaction(& : Transaction -> T) : T? forall T
tx = begin_transaction
# TODO: Cast to workaround crystal-lang/crystal#9483
# begin_transaction returns a Tx where Tx < Transaction
tx = begin_transaction.as(Transaction)
begin
res = yield tx
rescue DB::Rollback