SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.18k stars 1.9k forks source link

[Bug]: Docs are wrong regarding transactions and batch imports #4145

Closed Stalinko closed 1 week ago

Stalinko commented 2 months ago

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

What version of Laravel Excel are you using?

3.1.44

What version of Laravel are you using?

v8.83.25

What version of PHP are you using?

8.0

Describe your issue

https://docs.laravel-excel.com/3.1/imports/validation.html#database-transactions The docs are saying:

The entire import is automatically wrapped in a database transaction, that means that every error will rollback the entire import. When using batch inserts, only the current batch will be rollbacked

But in fact the entire import is wrapped into a single transaction, thus if there are multiple batches and one of them contains an error then all batches will be rollbacked.

How can the issue be reproduced?

Try to import a file with multiple batches. Some batch should contain a validation error.

None of the batches will be imported in the end.

What should be the expected behaviour?

All batches except the batch with error are imported.

Stalinko commented 2 months ago

Actually I like this behaviour more. So for me it's not a bug, but a feature.

And I'd suggest to update the docs accordingly - so that it says that entire import will be rollbacked even in the case of batch imports.

If you approve this - I can push a PR to the docs.

stale[bot] commented 1 week ago

This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.