laravel-csv-seeder icon indicating copy to clipboard operation
laravel-csv-seeder copied to clipboard

Does not show error message when database throws an error

Open glupeksha opened this issue 3 years ago • 8 comments

I got the "Seeded:" message but the csv file was not seeded because of a database error(forgotten to make a column nullable). I wasted lot of time to figure out the error. It would be wonderful it it can throw if there is any database error.

PS: Thanks for providing this library for free. It was really helpful.

glupeksha avatar Sep 09 '20 09:09 glupeksha

Same issue, I struggled above today. But anyway, thanks for the great library!

dashart-ke avatar Sep 21 '20 11:09 dashart-ke

Shot in the dark

a21ns1g4ts avatar Oct 19 '20 02:10 a21ns1g4ts

Same for me. Spend an hour to find the bug that caused my tests to fail after a laravel 8 upgrade. The seeds were not working anymore because the seed folder got renamed to "seeders". Please throw an error if the importer can not find the csv file. This is quite easy to implement. At the moment this is only logged https://github.com/Flynsarmy/laravel-csv-seeder/blob/c770b291978fc8680cf68e0fa7b33e1e8690219b/src/CsvSeeder.php#L133

Please throw an error here https://github.com/Flynsarmy/laravel-csv-seeder/blob/c770b291978fc8680cf68e0fa7b33e1e8690219b/src/CsvSeeder.php#L160-L162

ben182 avatar Nov 19 '20 20:11 ben182

@ben182 The problem described in your comment is fixed through https://github.com/Flynsarmy/laravel-csv-seeder/commit/e1774b1b38faa4f380bf5e450d8ecb7db834ec2e

Your comment should have been its own issue as it's different to OPs though.

Flynsarmy avatar Jan 04 '21 03:01 Flynsarmy

I don't really like the idea of throwing an Exception on DB error as this may result in the CSV being partially imported which will complicate matters further when a second attempt to import is made.

Do we have any other suggestions?

Flynsarmy avatar Jan 04 '21 03:01 Flynsarmy

Maybe an echo output of a warning with some error details could be help nor write of same details to the laravel log files + a note to the cmd line. The current silent fail is the main problem.

dashart-ke avatar Jan 05 '21 10:01 dashart-ke

Hi,

I'm using version 2.0.5 and it's the first time I try out the package. It's not throwing any error nor importing the data into the database.

I just get a "Seeded:" notice.

I'm using PHP8 with Laravel 8.27.

Has this been fixed in a non-released version?

Thanks in advance.

moetanahy avatar Feb 27 '21 21:02 moetanahy

I don't really like the idea of throwing an Exception on DB error as this may result in the CSV being partially imported which will complicate matters further when a second attempt to import is made.

Do we have any other suggestions?

Make it configurable with a flag to either raise the exception or silently ignore it? Also, seedFromCsv returns $success, but also the run function should return this.

I'm using the CsvSeeder to load test data for development, if the data is invalid (failing database constraints) I would like the seeding process to halt so the issue can be resolved.

jspaans avatar Aug 18 '21 11:08 jspaans