active_admin_import icon indicating copy to clipboard operation
active_admin_import copied to clipboard

Calling batch_slice_columns multiple times results in unexpected behavior

Open clinejj opened this issue 4 years ago • 0 comments

Given a file with the headers: supplier,sku,name,description,shipping,price,quantity_unit,minimum_quantity,maximum_quantity

After running in a before_batch_import callback, importer.batch_slice_columns(%w[supplier sku price minimum_quantity maximum_quantity]) the headers are sliced as expected.

However, if I wanted to further reduce the results set, calling importer.batch_slice_columns(%w[sku price minimum_quantity maximum_quantity]) does not reduce the csv_lines as expected due to @use_indexes here referring to the original indices but not the resulting indices.

This ends up replacing the values unexpectedly (since it uses the indices in @use_indexes which may no longer apply to the sliced results).

Ideally, running batch_slice_columns multiple times would continually reduce the column set based on the results of the prior call.

clinejj avatar Jan 05 '21 21:01 clinejj