From fb6b0ec08efd46fd91e3a94cad86e8be9463c4ad Mon Sep 17 00:00:00 2001 From: Jan Scheurer Date: Wed, 29 May 2024 13:09:19 +0200 Subject: [PATCH] Add test case for bulk upsert automatic key error --- src/sscce-sequelize-6.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/sscce-sequelize-6.ts b/src/sscce-sequelize-6.ts index 132a311d5..07a7d6b2d 100644 --- a/src/sscce-sequelize-6.ts +++ b/src/sscce-sequelize-6.ts @@ -15,16 +15,16 @@ export async function run() { const sequelize = createSequelize6Instance({ logQueryParameters: true, benchmark: true, - define: { - // For less clutter in the SSCCE - timestamps: false, - }, }); class Foo extends Model {} Foo.init({ - name: DataTypes.TEXT, + id: { + type: DataTypes.UUID, + defaultValue: DataTypes.UUIDV4, + primaryKey: true + }, }, { sequelize, modelName: 'Foo', @@ -36,6 +36,9 @@ export async function run() { await sequelize.sync({ force: true }); expect(spy).to.have.been.called; - console.log(await Foo.create({ name: 'TS foo' })); + expect(Foo.bulkCreate( + [{ id: 'e8388762-1daa-11ef-b9f0-b7d47c40e7e3' }], + { updateOnDuplicate: ['createdAt'] } + )).to.not.be.rejected(); expect(await Foo.count()).to.equal(1); }