Sha256: 231dd07cb96dea18c3e0a8cc9333cfc883a015984cedd52e661586c99ee0b612

Contents?: true

Size: 1.07 KB

Versions: 47

Compression:

Stored size: 1.07 KB

Contents

require 'switchman/sharded_instrumenter'

module Switchman
  module ActiveRecord
    module AbstractAdapter
      module ForeignKeyCheck
        def add_column(table, name, type, options = {})
          Engine.foreign_key_check(name, type, options)
          super
        end
      end

      attr_writer :shard
      attr_reader :last_query_at

      def shard
        @shard || Shard.default
      end

      def initialize(*args)
        super
        @instrumenter = Switchman::ShardedInstrumenter.new(@instrumenter, self)
        @last_query_at = Time.now
      end

      def quote_local_table_name(name)
        quote_table_name(name)
      end

      def use_qualified_names?
        false
      end

      protected

      def log(*args, &block)
        super
      ensure
        @last_query_at = Time.now
      end

      private

      def id_value_for_database(value)
        return super unless value.class.sharded_primary_key?
        # do this the Rails 4.2 way, so that if Shard.current != self.shard, the id gets transposed
        quote(value.id)
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
switchman-1.15.2 lib/switchman/active_record/abstract_adapter.rb
switchman-1.15.1 lib/switchman/active_record/abstract_adapter.rb
switchman-1.15.0 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.10 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.9 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.8 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.7 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.6 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.5 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.4 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.3 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.2 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.1 lib/switchman/active_record/abstract_adapter.rb
switchman-1.14.0 lib/switchman/active_record/abstract_adapter.rb
switchman-1.13.3 lib/switchman/active_record/abstract_adapter.rb
switchman-1.13.2 lib/switchman/active_record/abstract_adapter.rb
switchman-1.13.1 lib/switchman/active_record/abstract_adapter.rb
switchman-1.13.0 lib/switchman/active_record/abstract_adapter.rb
switchman-1.12.16 lib/switchman/active_record/abstract_adapter.rb
switchman-1.12.15 lib/switchman/active_record/abstract_adapter.rb