<commit_before>module ActiveRecord::Turntable
  module ActiveRecordExt
    module Transactions
      def with_transaction_returning_status
        if self.class.turntable_enabled?
          status = nil
          if self.new_record? and self.turntable_shard_key.to_s == self.class.primary_key and
              self.id.nil? and connection.prefetch_primary_key?(self.class.table_name)
            self.id = connection.next_sequence_value(self.class.sequence_name)
          end
          self.class.connection.shards_transaction([self.turntable_shard]) do
            add_to_transaction
            begin
              status = yield
            rescue ActiveRecord::Rollback
              @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) - 1
              status = nil
            end

            raise ActiveRecord::Rollback unless status
          end
          status
        else
          super
        end
      end

      def add_to_transaction
        if self.class.turntable_enabled?
          if self.turntable_shard.connection.add_transaction_record(self)
            remember_transaction_record_state
          end
        else
          super
        end
      end
    end
  end
end
<commit_msg>Remove deprecation warnings about AR::Base#connection<commit_after>module ActiveRecord::Turntable
  module ActiveRecordExt
    module Transactions
      def with_transaction_returning_status
        if self.class.turntable_enabled?
          status = nil
          if self.new_record? and self.turntable_shard_key.to_s == self.class.primary_key and
              self.id.nil? and self.class.connection.prefetch_primary_key?(self.class.table_name)
            self.id = self.class.connection.next_sequence_value(self.class.sequence_name)
          end
          self.class.connection.shards_transaction([self.turntable_shard]) do
            add_to_transaction
            begin
              status = yield
            rescue ActiveRecord::Rollback
              @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) - 1
              status = nil
            end

            raise ActiveRecord::Rollback unless status
          end
          status
        else
          super
        end
      end

      def add_to_transaction
        if self.class.turntable_enabled?
          if self.turntable_shard.connection.add_transaction_record(self)
            remember_transaction_record_state
          end
        else
          super
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.05717665615141956, 'fraction_numerical': 0.0015772870662460567, 'mean_word_length': 1.9603267211201867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5934820', 'n_tokens_mistral': 687, 'n_tokens_neox': 659, 'n_words': 132}