Report abuse

module ActiveRecord
  class Base
    class << self # fyi wordpress might screw up the double left
      def isolation_dirty()
        connection.dirty()
      end

      def isolation_clean()
        connection.clean()
      end

      def isolation_reallyclean()
        connection.reallyclean()
      end
    end
  end
end

module ActiveRecord
  module ConnectionAdapters
    module DatabaseStatements
      def dirty()
        raise NotImplementedError, "dirty is an abstract method"
      end
      def clean()
        raise NotImplementedError, "clean is an abstract method"
      end
      def reallyclean()
        raise NotImplementedError, "reallyclean is an abstract method"
      end
    end
  end
end

module ActiveRecord
  module ConnectionAdapters    
    class MysqlAdapter
      def dirty()
        execute('SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED')
      end
      def clean()
        execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ')
      end
      def reallyclean()
        execute('SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED')
      end
    end
  end
end