Commit 44fef4fe authored by Jasper Maes's avatar Jasper Maes

Remove rails 4 support in CI, Gemfiles, bin/ and config/

parent eafc8e2f
...@@ -77,18 +77,6 @@ stages: ...@@ -77,18 +77,6 @@ stages:
- mysql:5.7 - mysql:5.7
- redis:alpine - redis:alpine
.rails4: &rails4
allow_failure: false
except:
variables:
- $CI_COMMIT_REF_NAME =~ /(^docs[\/-].*|.*-docs$)/
- $CI_COMMIT_REF_NAME =~ /(^qa[\/-].*|.*-qa$)/
- $CI_COMMIT_REF_NAME =~ /norails4/
- $RAILS5_DISABLED
variables:
BUNDLE_GEMFILE: "Gemfile.rails4"
RAILS5: "false"
# Skip all jobs except the ones that begin with 'docs/'. # Skip all jobs except the ones that begin with 'docs/'.
# Used for commits including ONLY documentation changes. # Used for commits including ONLY documentation changes.
# https://docs.gitlab.com/ce/development/documentation/#testing # https://docs.gitlab.com/ce/development/documentation/#testing
...@@ -180,18 +168,10 @@ stages: ...@@ -180,18 +168,10 @@ stages:
<<: *rspec-metadata <<: *rspec-metadata
<<: *use-pg <<: *use-pg
.rspec-metadata-pg-rails4: &rspec-metadata-pg-rails4
<<: *rspec-metadata-pg
<<: *rails4
.rspec-metadata-mysql: &rspec-metadata-mysql .rspec-metadata-mysql: &rspec-metadata-mysql
<<: *rspec-metadata <<: *rspec-metadata
<<: *use-mysql <<: *use-mysql
.rspec-metadata-mysql-rails4: &rspec-metadata-mysql-rails4
<<: *rspec-metadata-mysql
<<: *rails4
.only-canonical-masters: &only-canonical-masters .only-canonical-masters: &only-canonical-masters
only: only:
- master@gitlab-org/gitlab-ce - master@gitlab-org/gitlab-ce
...@@ -432,7 +412,6 @@ setup-test-env: ...@@ -432,7 +412,6 @@ setup-test-env:
script: script:
- bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init' - bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init'
- scripts/gitaly-test-build # Do not use 'bundle exec' here - scripts/gitaly-test-build # Do not use 'bundle exec' here
- BUNDLE_GEMFILE=Gemfile.rails4 bundle install $BUNDLE_INSTALL_FLAGS
artifacts: artifacts:
expire_in: 7d expire_in: 7d
paths: paths:
...@@ -513,14 +492,6 @@ rspec-mysql: ...@@ -513,14 +492,6 @@ rspec-mysql:
<<: *rspec-metadata-mysql <<: *rspec-metadata-mysql
parallel: 50 parallel: 50
rspec-pg-rails4:
<<: *rspec-metadata-pg-rails4
parallel: 50
rspec-mysql-rails4:
<<: *rspec-metadata-mysql-rails4
parallel: 50
static-analysis: static-analysis:
<<: *dedicated-no-docs-no-db-pull-cache-job <<: *dedicated-no-docs-no-db-pull-cache-job
dependencies: dependencies:
...@@ -565,12 +536,6 @@ downtime_check: ...@@ -565,12 +536,6 @@ downtime_check:
- /(^docs[\/-].*|.*-docs$)/ - /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/ - /(^qa[\/-].*|.*-qa$)/
rails4_gemfile_lock_check:
<<: *dedicated-no-docs-no-db-pull-cache-job
<<: *except-docs-and-qa
script:
- scripts/rails4-gemfile-lock-check
ee_compat_check: ee_compat_check:
<<: *rake-exec <<: *rake-exec
dependencies: [] dependencies: []
......
# --- Special code for migrating to Rails 5.0 ---
def rails5?
!%w[0 false].include?(ENV["RAILS5"])
end
gem_versions = {}
gem_versions['activerecord_sane_schema_dumper'] = rails5? ? '1.0' : '0.2'
gem_versions['rails'] = rails5? ? '5.0.7' : '4.2.11'
gem_versions['rails-i18n'] = rails5? ? '~> 5.1' : '~> 4.0.9'
# The 2.0.6 version of rack requires monkeypatch to be present in
# `config.ru`. This can be removed once a new update for Rack
# is available that contains https://github.com/rack/rack/pull/1201.
gem_versions['rack'] = rails5? ? '2.0.6' : '1.6.11'
# --- The end of special code for migrating to Rails 5.0 ---
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'rails', gem_versions['rails'] gem 'rails', '5.0.7'
gem 'rails-deprecated_sanitizer', '~> 1.0.3' gem 'rails-deprecated_sanitizer', '~> 1.0.3'
# Improves copy-on-write performance for MRI # Improves copy-on-write performance for MRI
...@@ -28,11 +12,7 @@ gem 'responders', '~> 2.0' ...@@ -28,11 +12,7 @@ gem 'responders', '~> 2.0'
gem 'sprockets', '~> 3.7.0' gem 'sprockets', '~> 3.7.0'
# Default values for AR models # Default values for AR models
if rails5? gem 'gitlab-default_value_for', '~> 3.1.1', require: 'default_value_for'
gem 'gitlab-default_value_for', '~> 3.1.1', require: 'default_value_for'
else
gem 'default_value_for', '~> 3.0.0'
end
# Supported DBs # Supported DBs
gem 'mysql2', '~> 0.4.10', group: :mysql gem 'mysql2', '~> 0.4.10', group: :mysql
...@@ -159,7 +139,10 @@ gem 'icalendar' ...@@ -159,7 +139,10 @@ gem 'icalendar'
gem 'diffy', '~> 3.1.0' gem 'diffy', '~> 3.1.0'
# Application server # Application server
gem 'rack', gem_versions['rack'] # The 2.0.6 version of rack requires monkeypatch to be present in
# `config.ru`. This can be removed once a new update for Rack
# is available that contains https://github.com/rack/rack/pull/1201.
gem 'rack', '2.0.6'
group :unicorn do group :unicorn do
gem 'unicorn', '~> 5.1.0' gem 'unicorn', '~> 5.1.0'
...@@ -297,7 +280,7 @@ gem 'premailer-rails', '~> 1.9.7' ...@@ -297,7 +280,7 @@ gem 'premailer-rails', '~> 1.9.7'
# I18n # I18n
gem 'ruby_parser', '~> 3.8', require: false gem 'ruby_parser', '~> 3.8', require: false
gem 'rails-i18n', gem_versions['rails-i18n'] gem 'rails-i18n', '~> 5.1'
gem 'gettext_i18n_rails', '~> 1.8.0' gem 'gettext_i18n_rails', '~> 1.8.0'
gem 'gettext_i18n_rails_js', '~> 1.3' gem 'gettext_i18n_rails_js', '~> 1.3'
gem 'gettext', '~> 3.2.2', require: false, group: :development gem 'gettext', '~> 3.2.2', require: false, group: :development
...@@ -383,7 +366,7 @@ group :development, :test do ...@@ -383,7 +366,7 @@ group :development, :test do
gem 'license_finder', '~> 5.4', require: false gem 'license_finder', '~> 5.4', require: false
gem 'knapsack', '~> 1.17' gem 'knapsack', '~> 1.17'
gem 'activerecord_sane_schema_dumper', gem_versions['activerecord_sane_schema_dumper'] gem 'activerecord_sane_schema_dumper', '1.0'
gem 'stackprof', '~> 0.2.10', require: false gem 'stackprof', '~> 0.2.10', require: false
...@@ -397,8 +380,7 @@ group :test do ...@@ -397,8 +380,7 @@ group :test do
gem 'email_spec', '~> 2.2.0' gem 'email_spec', '~> 2.2.0'
gem 'json-schema', '~> 2.8.0' gem 'json-schema', '~> 2.8.0'
gem 'webmock', '~> 2.3.2' gem 'webmock', '~> 2.3.2'
gem 'rails-controller-testing' if rails5? # Rails5 only gem. gem 'rails-controller-testing'
gem 'test_after_commit', '~> 1.1' unless rails5? # Remove this gem when migrated to rails 5.0. It's been integrated to rails 5.0.
gem 'sham_rack', '~> 1.3.6' gem 'sham_rack', '~> 1.3.6'
gem 'concurrent-ruby', '~> 1.1' gem 'concurrent-ruby', '~> 1.1'
gem 'test-prof', '~> 0.2.5' gem 'test-prof', '~> 0.2.5'
......
# BUNDLE_GEMFILE=Gemfile.rails4 bundle install
ENV["RAILS5"] = "false"
gemfile = File.expand_path("../Gemfile", __FILE__)
eval(File.read(gemfile), nil, gemfile)
This diff is collapsed.
#!/usr/bin/env ruby #!/usr/bin/env ruby
# Remove this block when upgraded to rails 5.0.
if %w[0 false].include?(ENV["RAILS5"])
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
end
APP_PATH = File.expand_path('../config/application', __dir__) APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot' require_relative '../config/boot'
require 'rails/commands' require 'rails/commands'
#!/usr/bin/env ruby #!/usr/bin/env ruby
# Remove this block when upgraded to rails 5.0.
if %w[0 false].include?(ENV["RAILS5"])
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
end
require_relative '../config/boot' require_relative '../config/boot'
require 'rake' require 'rake'
Rake.application.run Rake.application.run
#!/usr/bin/env ruby #!/usr/bin/env ruby
# Remove these two lines below when upgraded to rails 5.0.
# Allow run `rspec` command as `RAILS5=1 rspec ...` instead of `BUNDLE_GEMFILE=Gemfile.rails5 rspec ...`
gemfile = %w[0 false].include?(ENV["RAILS5"]) ? "Gemfile.rails4" : "Gemfile"
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../#{gemfile}", __dir__)
begin begin
load File.expand_path('../spring', __FILE__) load File.expand_path('../spring', __FILE__)
rescue LoadError => e rescue LoadError => e
......
#!/usr/bin/env ruby #!/usr/bin/env ruby
def rails5?
!%w[0 false].include?(ENV["RAILS5"])
end
require "pathname" require "pathname"
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path("../../", __FILE__) APP_ROOT = Pathname.new File.expand_path("../../", __FILE__)
if rails5? def system!(*args)
def system!(*args) system(*args) || abort("\n== Command #{args} failed ==")
system(*args) || abort("\n== Command #{args} failed ==")
end
end end
Dir.chdir APP_ROOT do Dir.chdir APP_ROOT do
...@@ -20,14 +14,8 @@ Dir.chdir APP_ROOT do ...@@ -20,14 +14,8 @@ Dir.chdir APP_ROOT do
# Add necessary setup steps to this file: # Add necessary setup steps to this file:
puts "== Installing dependencies ==" puts "== Installing dependencies =="
system! "gem install bundler --conservative"
if rails5? system("bundle check") || system!("bundle install")
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
else
system "gem install bundler --conservative"
system "bundle check || bundle install"
end
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml") # unless File.exist?("config/database.yml")
...@@ -35,27 +23,11 @@ Dir.chdir APP_ROOT do ...@@ -35,27 +23,11 @@ Dir.chdir APP_ROOT do
# end # end
puts "\n== Preparing database ==" puts "\n== Preparing database =="
system! "bin/rails db:setup"
if rails5?
system! "bin/rails db:setup"
else
system "bin/rake db:reset"
end
puts "\n== Removing old logs and tempfiles ==" puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
if rails5?
system! "bin/rails log:clear tmp:clear"
else
system "rm -f log/*"
system "rm -rf tmp/cache"
end
puts "\n== Restarting application server ==" puts "\n== Restarting application server =="
system! "bin/rails restart"
if rails5?
system! "bin/rails restart"
else
system "touch tmp/restart.txt"
end
end end
---
title: Remove rails 4 support in CI, Gemfiles, bin/ and config/
merge_request: 23717
author: Jasper Maes
type: other
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
# This method is used for smooth upgrading from the current Rails 4.x to Rails 5.0. # This method is used for smooth upgrading from the current Rails 4.x to Rails 5.0.
# https://gitlab.com/gitlab-org/gitlab-ce/issues/14286 # https://gitlab.com/gitlab-org/gitlab-ce/issues/14286
def self.rails5? def self.rails5?
!%w[0 false].include?(ENV["RAILS5"]) true
end end
class Application < Rails::Application class Application < Rails::Application
...@@ -26,9 +26,6 @@ module Gitlab ...@@ -26,9 +26,6 @@ module Gitlab
# setting disabled # setting disabled
require_dependency Rails.root.join('lib/mysql_zero_date') require_dependency Rails.root.join('lib/mysql_zero_date')
# This can be removed when we drop support for rails 4
require_dependency Rails.root.join('lib/rails4_migration_version')
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers # Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
...@@ -86,7 +83,7 @@ module Gitlab ...@@ -86,7 +83,7 @@ module Gitlab
# namespaces/users. # namespaces/users.
# https://github.com/rails/rails/blob/5-0-stable/actioncable/lib/action_cable.rb#L38 # https://github.com/rails/rails/blob/5-0-stable/actioncable/lib/action_cable.rb#L38
# Please change this value when configuring ActionCable for real usage. # Please change this value when configuring ActionCable for real usage.
config.action_cable.mount_path = "/-/cable" if rails5? config.action_cable.mount_path = "/-/cable"
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.
# #
...@@ -213,8 +210,6 @@ module Gitlab ...@@ -213,8 +210,6 @@ module Gitlab
config.cache_store = :redis_store, caching_config_hash config.cache_store = :redis_store, caching_config_hash
config.active_record.raise_in_transactional_callbacks = true unless rails5?
config.active_job.queue_adapter = :sidekiq config.active_job.queue_adapter = :sidekiq
# This is needed for gitlab-shell # This is needed for gitlab-shell
......
def rails5? ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
!%w[0 false].include?(ENV["RAILS5"])
end
require 'rubygems' unless rails5?
gemfile = rails5? ? "Gemfile" : "Gemfile.rails4"
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../#{gemfile}", __dir__)
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
......
# Load the rails application # Load the rails application
# Remove this condition when upgraded to rails 5.0. require_relative 'application'
if %w[0 false].include?(ENV["RAILS5"])
require File.expand_path('application', __dir__)
else
require_relative 'application'
end
# Initialize the rails application # Initialize the rails application
Rails.application.initialize! Rails.application.initialize!
...@@ -9,11 +9,7 @@ Rails.application.configure do ...@@ -9,11 +9,7 @@ Rails.application.configure do
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this) # Disable Rails's static asset server (Apache or nginx will already do this)
if Gitlab.rails5? config.public_file_server.enabled = false
config.public_file_server.enabled = false
else
config.serve_static_files = false
end
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
......
...@@ -19,13 +19,8 @@ Rails.application.configure do ...@@ -19,13 +19,8 @@ Rails.application.configure do
# Configure static asset server for tests with Cache-Control for performance # Configure static asset server for tests with Cache-Control for performance
config.assets.compile = false if ENV['CI'] config.assets.compile = false if ENV['CI']
if Gitlab.rails5? config.public_file_server.enabled = true
config.public_file_server.enabled = true config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
else
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
end
# Show full error reports and disable caching # Show full error reports and disable caching
config.consider_all_requests_local = true config.consider_all_requests_local = true
......
# Remove this initializer when upgraded to Rails 5.0
unless Gitlab.rails5?
module ActiveRecord
class PredicateBuilder
class ArrayHandler
module TypeCasting
def call(attribute, value)
# This is necessary because by default ActiveRecord does not respect
# custom type definitions (like our `ShaAttribute`) when providing an
# array in `where`, like in `where(commit_sha: [sha1, sha2, sha3])`.
model = attribute.relation&.engine
type = model.user_provided_columns[attribute.name] if model
value = value.map { |value| type.type_cast_for_database(value) } if type
super(attribute, value)
end
end
prepend TypeCasting
end
end
end
end
...@@ -20,75 +20,73 @@ ...@@ -20,75 +20,73 @@
# #
# This bug was fixed in Rails 5.1 by https://github.com/rails/rails/pull/24745/commits/aa062318c451512035c10898a1af95943b1a3803 # This bug was fixed in Rails 5.1 by https://github.com/rails/rails/pull/24745/commits/aa062318c451512035c10898a1af95943b1a3803
if Gitlab.rails5? if Rails.version.start_with?("5.1")
if Rails.version.start_with?("5.1") raise "Remove this monkey patch: #{__FILE__}"
raise "Remove this monkey patch: #{__FILE__}" end
end
# Copy-paste from https://github.com/kamipo/rails/blob/aa062318c451512035c10898a1af95943b1a3803/activerecord/lib/active_record/validations/uniqueness.rb # Copy-paste from https://github.com/kamipo/rails/blob/aa062318c451512035c10898a1af95943b1a3803/activerecord/lib/active_record/validations/uniqueness.rb
# including local fixes to make Rubocop happy again. # including local fixes to make Rubocop happy again.
module ActiveRecord module ActiveRecord
module Validations module Validations
class UniquenessValidator < ActiveModel::EachValidator # :nodoc: class UniquenessValidator < ActiveModel::EachValidator # :nodoc:
def validate_each(record, attribute, value) def validate_each(record, attribute, value)
finder_class = find_finder_class_for(record) finder_class = find_finder_class_for(record)
table = finder_class.arel_table table = finder_class.arel_table
value = map_enum_attribute(finder_class, attribute, value) value = map_enum_attribute(finder_class, attribute, value)
relation = build_relation(finder_class, table, attribute, value) relation = build_relation(finder_class, table, attribute, value)
if record.persisted? if record.persisted?
if finder_class.primary_key if finder_class.primary_key
relation = relation.where.not(finder_class.primary_key => record.id_was || record.id) relation = relation.where.not(finder_class.primary_key => record.id_was || record.id)
else else
raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.") raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.")
end
end end
end
relation = scope_relation(record, table, relation) relation = scope_relation(record, table, relation)
relation = relation.merge(options[:conditions]) if options[:conditions] relation = relation.merge(options[:conditions]) if options[:conditions]
if relation.exists? if relation.exists?
error_options = options.except(:case_sensitive, :scope, :conditions) error_options = options.except(:case_sensitive, :scope, :conditions)
error_options[:value] = value error_options[:value] = value
record.errors.add(attribute, :taken, error_options) record.errors.add(attribute, :taken, error_options)
end
rescue RangeError
end end
rescue RangeError
end
protected protected
def build_relation(klass, table, attribute, value) #:nodoc:
if reflection = klass._reflect_on_association(attribute)
attribute = reflection.foreign_key
value = value.attributes[reflection.klass.primary_key] unless value.nil?
end
# the attribute may be an aliased attribute def build_relation(klass, table, attribute, value) #:nodoc:
if klass.attribute_alias?(attribute) if reflection = klass._reflect_on_association(attribute)
attribute = klass.attribute_alias(attribute) attribute = reflection.foreign_key
end value = value.attributes[reflection.klass.primary_key] unless value.nil?
end
attribute_name = attribute.to_s # the attribute may be an aliased attribute
if klass.attribute_alias?(attribute)
attribute = klass.attribute_alias(attribute)
end
column = klass.columns_hash[attribute_name] attribute_name = attribute.to_s
cast_type = klass.type_for_attribute(attribute_name)
comparison = column = klass.columns_hash[attribute_name]
if !options[:case_sensitive] && !value.nil? cast_type = klass.type_for_attribute(attribute_name)
# will use SQL LOWER function before comparison, unless it detects a case insensitive collation
klass.connection.case_insensitive_comparison(table, attribute, column, value)
else
klass.connection.case_sensitive_comparison(table, attribute, column, value)
end
if value.nil? comparison =
klass.unscoped.where(comparison) if !options[:case_sensitive] && !value.nil?
# will use SQL LOWER function before comparison, unless it detects a case insensitive collation
klass.connection.case_insensitive_comparison(table, attribute, column, value)
else else
bind = Relation::QueryAttribute.new(attribute_name, value, cast_type) klass.connection.case_sensitive_comparison(table, attribute, column, value)
klass.unscoped.where(comparison, bind)
end end
if value.nil?
klass.unscoped.where(comparison)
else
bind = Relation::QueryAttribute.new(attribute_name, value, cast_type)
klass.unscoped.where(comparison, bind)
end end
end end
end end
......
...@@ -65,7 +65,7 @@ elsif Gitlab::Database.mysql? ...@@ -65,7 +65,7 @@ elsif Gitlab::Database.mysql?
prepend RegisterDateTimeWithTimeZone prepend RegisterDateTimeWithTimeZone
# Add the class `DateTimeWithTimeZone` so we can map `timestamp` to it. # Add the class `DateTimeWithTimeZone` so we can map `timestamp` to it.
class MysqlDateTimeWithTimeZone < (Gitlab.rails5? ? ActiveRecord::Type::DateTime : MysqlDateTime) class MysqlDateTimeWithTimeZone < ActiveRecord::Type::DateTime
def type def type
:datetime_with_timezone :datetime_with_timezone
end end
......
...@@ -64,21 +64,13 @@ module ActiveRecord ...@@ -64,21 +64,13 @@ module ActiveRecord
# This is patched because we want `lock_version` default to `NULL` # This is patched because we want `lock_version` default to `NULL`
# rather than `0` # rather than `0`
if Gitlab.rails5? class LockingType
class LockingType def deserialize(value)
def deserialize(value) super
super
end
def serialize(value)
super
end
end end
else
class LockingType < SimpleDelegator def serialize(value)
def type_cast_from_database(value) super
super
end
end end
end end
end end
......
# Remove this `if` condition when upgraded to rails 5.0.
# The body must be kept.
if Gitlab.rails5?
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end
end
# Remove this file when upgraded to rails 5.0.
unless Gitlab.rails5?
module ActiveRecord
module Batches
# Differences from upstream: enumerator support was removed, and custom
# order/limit clauses are ignored without a warning.
def in_batches(of: 1000, start: nil, finish: nil, load: false)
raise "Must provide a block" unless block_given?
relation = self.reorder(batch_order).limit(of)
relation = relation.where(arel_table[primary_key].gteq(start)) if start
relation = relation.where(arel_table[primary_key].lteq(finish)) if finish
batch_relation = relation
loop do
if load
records = batch_relation.records
ids = records.map(&:id)
yielded_relation = self.where(primary_key => ids)
yielded_relation.load_records(records)
else
ids = batch_relation.pluck(primary_key)
yielded_relation = self.where(primary_key => ids)
end