lib/pgslice.rb in pgslice-0.3.1 vs lib/pgslice.rb in pgslice-0.3.2

- old
+ new

@@ -241,23 +241,22 @@ end end primary_key = self.primary_key(table) max_source_id = max_id(source_table, primary_key) + max_dest_id = - if options[:swapped] + if options[:start] + options[:start] + elsif options[:swapped] max_id(dest_table, primary_key, where: options[:where], below: max_source_id) else max_id(dest_table, primary_key, where: options[:where]) end if max_dest_id == 0 && !options[:swapped] - if options[:start] - max_dest_id = options[:start] - else - min_source_id = min_id(source_table, primary_key, field, cast, starting_time, options[:where]) - max_dest_id = min_source_id - 1 if min_source_id - end + min_source_id = min_id(source_table, primary_key, field, cast, starting_time, options[:where]) + max_dest_id = min_source_id - 1 if min_source_id end starting_id = max_dest_id fields = columns(source_table).map { |c| PG::Connection.quote_ident(c) }.join(", ") batch_size = options[:batch_size]