lib/evil_seed/relation_dumper.rb in evil-seed-0.4.0 vs lib/evil_seed/relation_dumper.rb in evil-seed-0.5.0
- old
+ new
@@ -58,10 +58,13 @@
end
private
def dump!
+ original_ignored_columns = model_class.ignored_columns
+ model_class.ignored_columns += Array(configuration.ignored_columns_for(model_class.sti_name))
+ model_class.send(:reload_schema_from_cache) if ActiveRecord.version < Gem::Version.new("6.1.0.rc1") # See https://github.com/rails/rails/pull/37581
if identifiers.present?
# Don't use AR::Base#find_each as we will get error on Oracle if we will have more than 1000 ids in IN statement
identifiers.in_groups_of(MAX_IDENTIFIERS_IN_IN_STMT).each do |ids|
fetch_attributes(relation.where(search_key => ids.compact)).each do |attributes|
next unless check_limits!
@@ -74,9 +77,11 @@
next unless check_limits!
dump_record!(attributes)
end
end
end
+ ensure
+ model_class.ignored_columns = original_ignored_columns
end
def dump_record!(attributes)
nullify_columns.each do |nullify_column|
attributes[nullify_column] = nil