jruby-9.2.8.0 :001 > require 'sequel'
=> true
jruby-9.2.8.0 :002 > require 'logger'
=> true
jruby-9.2.8.0 :003 > DB =
Sequel.connect('jdbc:jtds:sqlserver://localhost/activerecord_unittest;user=user;password=pass')
/Users/sdahlbacka/.rvm/gems/jruby-9.2.8.0/gems/sequel-5.7.1/lib/sequel/adapters/jdbc.rb:358:
warning: constant ::NativeException is deprecated
=> #<Sequel::JDBC::Database:
"jdbc:jtds:sqlserver://localhost/activerecord_unittest;user=user;password=pass">
jruby-9.2.8.0 :005 > DB.loggers << Logger.new($stdout)
=> [#<Logger:0x5a63f509 @default_formatter=#<Logger::Formatter:0x6e4784bc
@datetime_format=nil>, @level=0, @progname=nil, @formatter=nil,
@logdev=#<Logger::LogDevice:0x34b7ac2f @shift_age=nil,
@shift_period_suffix=nil, @filename=nil, @dev=#<IO:<STDOUT>>,
@mon_mutex=#<Thread::Mutex:0xe056f20>, @shift_size=nil, @mon_owner=nil,
@mon_count=0>>]
jruby-9.2.8.0 :006 > DB.transaction_isolation_level = :uncommitted
=> :uncommitted
jruby-9.2.8.0 :007 > DB[Sequel[:dbo][:users]].all
I, [2020-09-03T23:58:44.691897 #61015] INFO -- : (0.008017s) SELECT
CAST(SERVERPROPERTY('ProductVersion') AS varchar)
I, [2020-09-03T23:58:44.703652 #61015] INFO -- : (0.002332s) SELECT * FROM
[DBO].[USERS]
I would need the ' SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED' even
without an explicit transaction
/Simon
On Thu, Sep 3, 2020 at 11:14 PM Simon Dahlbacka <[email protected]>
wrote:
> Thanks,
>
> but AFAIK DB.transaction_isolation_level only works if I have explicit
> DB.transaction:s ?
>
> On Thu, Sep 3, 2020 at 11:09 PM Jeremy Evans <[email protected]>
> wrote:
>
>> 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
>> <https://groups.google.com/d/msgid/sequel-talk/d9797b0c-68b7-4c55-affe-2a9fa78bc6c1o%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
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/CAJJT2-fxW_TZnH7t6QRT6Q8qnMSSzSu7DY31SxMN4yLybbmxdQ%40mail.gmail.com.