Open MauritzFunke opened 2 years ago
Hello , For the test file it works because When using Model.build(), you can directly assign an object to the arr property, and Sequelize will store it as JSON in the database without any additional stringification. but when using bulkInsert you need to serialize arr value ['test1'] manually:
module.exports = {
async up (queryInterface, Sequelize) {
return queryInterface.bulkInsert('test',[
{
arr: JSON.stringify(['test1']),
createdAt: new Date(),
updatedAt: new Date()
}
])
},
async down (queryInterface, Sequelize) {
return queryInterface.bulkDelete('test', null, {});
}
};
so i assume , this is not a bug
Thanks for your help! I had the same problem and searched for a long time before seeing your comment. You solved my bug. Thank you again!
What you are doing?
I used
npx sequelize db:seed:all
to seed a database entry. If I try to create it in the project itself everything is working fine (see test file)Test File
Model File
Seed File
What do you expect to happen?
Insert a new row into the database with the array
What is actually happening?
The array isnt beeing parsed to ['test1'], it's getting parsed to 'test1'
Dialect: mariadb Database version: 10.5.15 Sequelize CLI version: 6.4.1 Sequelize version: 6.21.6