On Monday, March 2, 2015 at 4:12:12 PM UTC-8, Jeremy Evans wrote:
>
> On Monday, March 2, 2015 at 3:26:52 PM UTC-8, Tim Bates wrote:
>>
>> On Tuesday, March 3, 2015 at 8:42:03 AM UTC+10:30, Jeremy Evans wrote:
>>>
>>>     def commit_transaction(conn, opts=OPTS)
>>>       if (!supports_savepoints? || savepoint_level(conn) == 1) && (ary = 
>>> _trans(conn)[:before_commit])
>>>         ary.each{|b| b.call}
>>>       end
>>>       super
>>>     end
>>>
>>
>> I tried this first but the transaction isn't rolled back if 
>> commit_transaction raises an exception.
>>
>
This may be a simpler approach:

    def _transaction(*)
      super do |conn|
        yield conn
        if (!supports_savepoints? || savepoint_level(conn) == 1) && (ary = 
_trans(conn)[:before_commit])
          ary.each{|b| b.call}
        end
      end
    end
 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to