Skip to content

Calling batch_slice_columns multiple times results in unexpected behavior #186

Open
@clinejj

Description

@clinejj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions