On Thursday, September 3, 2020 at 12:12:37 PM UTC-7, Simon Dahlbacka wrote:
>
> Hi,
>
> is there a smart way of setting transaction level without including it in
> the connect opts?
>
> Basically, I want to make it impossible to forget to set it as a courtesy
> to future me and coworkers.
>
> From reading the docs, it seems that
> https://www.rubydoc.info/gems/sequel/4.38.0/Sequel%2FDatabase.after_initialize
> is
> almost, but not quite what I want.
>
> I also found after_connect. Which does work, but that would require
> passing it in in every connect call, as I did not manage to override
> Sequel::OPTS.
>
> Is there a way I'm not seeing?
>
DB.transaction_isolation_level = :serializable
This sets the default transaction isolation level, which you can override
on a per-transaction basis. Example:
DB.transaction_isolation_level = :serializable
DB.transaction{}
BEGIN TRANSACTION
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
COMMIT TRANSACTION
DB.transaction(:isolation=>:committed){}
BEGIN TRANSACTION
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
COMMIT TRANSACTION
See
http://sequel.jeremyevans.net/rdoc/classes/Sequel/Database.html#attribute-i-transaction_isolation_level
Thanks,
Jeremy
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/d9797b0c-68b7-4c55-affe-2a9fa78bc6c1o%40googlegroups.com.