jeroenzwart / laravel-csv-seeder

Seed your database with Laravel using CSV files
Other
92 stars 30 forks source link

Value with 0 changed into null when running db:seed #16

Closed efraim14 closed 4 years ago

efraim14 commented 4 years ago

Hello,

I am using this package to seed my data into DB, it was working months ago with the same CSV. But today, i tried to re-run my seeder and something weird happened.

I have CSV with these data : id;option;question_number;most;least;type;option_b;question_number_b 1;1;53;A;;C;0;0 2;3;53;C;;C;0;0

But everytime i tried to seed, the seeder always return error Rows of the file "/database/seeds/csv/TblMTestQuestion.csv" has been failed to insert: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'option_b' cannot be null (SQL: insert intotbl_m_test_questions(created_at,id,least,most,option,option_b,question_number,question_number_b,type,updated_at) values (2020-08-13 13:50:12, 1, ?, A, 1, ?, 53, ?, C, 2020-08-13 13:50:12), (2020-08-13 13:50:12, 2, ?, C, 3, ?, 53, ?, C, 2020-08-13 13:50:12)

I did not intend to seed a null value to the option_b column, i tried to set 0 on the integer field of option_b.

jeroenzwart commented 4 years ago

Hello,

You are right. A value with '0' is still empty by empty(). I added a fix in v1.3.1 for this