File: active_record_3.rb

package info (click to toggle)
ruby-test-prof 0.12.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 508 kB
  • sloc: ruby: 4,075; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 695 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module TestProf
  # Add missing `begin_transaction` and `rollback_transaction` methods
  module ActiveRecord3Transactions
    refine ::ActiveRecord::ConnectionAdapters::AbstractAdapter do
      def begin_transaction(joinable: true)
        if open_transactions > 0
          increment_open_transactions
          create_savepoint
        else
          begin_db_transaction
        end
        self.transaction_joinable = joinable
      end

      def rollback_transaction(*)
        if open_transactions > 1
          rollback_to_savepoint
        else
          rollback_db_transaction
        end
        decrement_open_transactions
      end
    end
  end
end