Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling batch_slice_columns multiple times results in unexpected behavior #186

Open
clinejj opened this issue Jan 5, 2021 · 0 comments
Open

Comments

@clinejj
Copy link
Contributor

clinejj commented Jan 5, 2021

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 clinejj changed the title Cannot run batch_slice_columns multiple times Calling batch_slice_columns multiple times results in unexpected behavior Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant