Sha256: 4d2306c86636c603a96e7d8893d3449a99ee9f0764d62df884fa17fe3bd027f0

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

module ActiveRecord::Turntable
  module ActiveRecordExt
    module AbstractAdapter
      extend ActiveSupport::Concern

      included do
        protected

        # @note override for logging current shard name
        def log(sql, name = "SQL", binds = [])
          @instrumenter.instrument(
                                   "sql.active_record",
                                   :sql           => sql,
                                   :name          => name,
                                   :connection_id => object_id,
                                   :binds         => binds,
                                   :turntable_shard_name => turntable_shard_name) { yield }
        rescue Exception => e
          message = "#{e.class.name}: #{e.message}: #{sql} : #{turntable_shard_name}"
          @logger.debug message if @logger
          exception = translate_exception(e, message)
          exception.set_backtrace e.backtrace
          raise exception
        end
      end

      def turntable_shard_name=(name)
        @turntable_shard_name = name.to_s
      end

      def turntable_shard_name
        @turntable_shard_name
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
activerecord-turntable-2.1.0.beta1 lib/active_record/turntable/active_record_ext/abstract_adapter.rb
activerecord-turntable-2.0.6 lib/active_record/turntable/active_record_ext/abstract_adapter.rb
activerecord-turntable-2.0.5 lib/active_record/turntable/active_record_ext/abstract_adapter.rb
activerecord-turntable-2.0.4 lib/active_record/turntable/active_record_ext/abstract_adapter.rb
activerecord-turntable-2.0.3 lib/active_record/turntable/active_record_ext/abstract_adapter.rb
activerecord-turntable-2.0.2 lib/active_record/turntable/active_record_ext/abstract_adapter.rb
activerecord-turntable-2.0.1 lib/active_record/turntable/active_record_ext/abstract_adapter.rb
activerecord-turntable-2.0.0 lib/active_record/turntable/active_record_ext/abstract_adapter.rb