Sha256: 9feb30b1ba1a9869cc93631564a0b1082b5204ceb16d3522dd92c4e45ac2bc68

Contents?: true

Size: 1.12 KB

Versions: 10

Compression:

Stored size: 1.12 KB

Contents

require 'active_record/connection_adapters/abstract/transaction'

module ActiveRecord
  module ConnectionAdapters

    module SQLServerTransaction

      private

      def sqlserver?
        connection.respond_to?(:sqlserver?) && connection.sqlserver?
      end

      def current_isolation_level
        return unless sqlserver?
        level = connection.user_options_isolation_level
        level.blank? ? 'READ COMMITTED' : level.upcase
      end

    end

    Transaction.send :include, SQLServerTransaction

    module SQLServerRealTransaction

      attr_reader :starting_isolation_level

      def initialize(connection, options)
        @connection = connection
        @starting_isolation_level = current_isolation_level if options[:isolation]
        super
      end

      def commit
        super
        reset_starting_isolation_level
      end

      private

      def reset_starting_isolation_level
        if sqlserver? && starting_isolation_level
          connection.set_transaction_isolation_level(starting_isolation_level)
        end
      end

    end

    RealTransaction.send :include, SQLServerRealTransaction

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activerecord-sqlserver-adapter-4.2.11 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.10 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.9 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.8 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.6 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.5 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.4 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.3 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.2 lib/active_record/connection_adapters/sqlserver/transaction.rb
activerecord-sqlserver-adapter-4.2.1 lib/active_record/connection_adapters/sqlserver/transaction.rb