Sha256: eb713389deb63a2690894ead7a2dbee2f43a4ab032ba90d436f419791d5309fe
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true require "active_record/associations/preloader" module ActiveRecord module ConnectionAdapters module SQLServer module CoreExt module Preloader private def records_for(ids) return super unless klass.connection.adapter_name == "SQLServer" ids.each_slice(in_clause_length).flat_map do |slice| scope.where(association_key_name => slice).load do |record| # Processing only the first owner # because the record is modified but not an owner owner = owners_by_key[convert_key(record[association_key_name])].first association = owner.association(reflection.name) association.set_inverse_instance(record) end.records end end def in_clause_length 10_000 end end end end end end ActiveSupport.on_load(:active_record) do mod = ActiveRecord::ConnectionAdapters::SQLServer::CoreExt::Preloader ActiveRecord::Associations::Preloader::Association.prepend(mod) end
Version data entries
5 entries across 5 versions & 1 rubygems