Sha256: 692c8468b32622404bdf91dc7b4848beb39f60bcf8d38e470718bf9da17fe428

Contents?: true

Size: 520 Bytes

Versions: 8

Compression:

Stored size: 520 Bytes

Contents

require "active_record/associations/preloader/association"

module ActiveRecord::Turntable
  module ActiveRecordExt
    module AssociationPreloader
      include ShardingCondition

      # @note Override to add sharding condition on preload
      def records_for(ids)
        returning_scope = super
        if should_use_shard_key?
          returning_scope = returning_scope.where(klass.turntable_shard_key => owners.map(&foreign_shard_key.to_sym).uniq)
        end
        returning_scope
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
activerecord-turntable-4.1.0 lib/active_record/turntable/active_record_ext/association_preloader.rb
activerecord-turntable-4.0.0 lib/active_record/turntable/active_record_ext/association_preloader.rb
activerecord-turntable-3.1.0 lib/active_record/turntable/active_record_ext/association_preloader.rb
activerecord-turntable-3.0.1 lib/active_record/turntable/active_record_ext/association_preloader.rb
activerecord-turntable-3.0.0 lib/active_record/turntable/active_record_ext/association_preloader.rb
activerecord-turntable-3.0.0.alpha3 lib/active_record/turntable/active_record_ext/association_preloader.rb
activerecord-turntable-3.0.0.alpha2 lib/active_record/turntable/active_record_ext/association_preloader.rb
activerecord-turntable-3.0.0.alpha1 lib/active_record/turntable/active_record_ext/association_preloader.rb