lib/blind_index/backfill.rb in blind_index-2.4.0 vs lib/blind_index/backfill.rb in blind_index-2.5.0

- old
+ new

@@ -2,11 +2,11 @@ class Backfill attr_reader :blind_indexes def initialize(relation, batch_size:, columns:) @relation = relation - @transaction = @relation.respond_to?(:transaction) + @transaction = @relation.respond_to?(:transaction) && !mongoid_relation?(relation.all) @batch_size = batch_size @blind_indexes = @relation.blind_indexes filter_columns!(columns) if columns end @@ -96,9 +96,13 @@ records.each do |record| record.save!(validate: false) end end end + end + + def mongoid_relation?(relation) + defined?(Mongoid::Criteria) && relation.is_a?(Mongoid::Criteria) end def with_transaction if @transaction @relation.transaction do