Skip to content

Commit 7ca9076

Browse files
author
Jan Scheurer
committed
Add test case for bulk upsert automatic key error
1 parent c8b54c3 commit 7ca9076

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/sscce-sequelize-6.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ export async function run() {
1515
const sequelize = createSequelize6Instance({
1616
logQueryParameters: true,
1717
benchmark: true,
18-
define: {
19-
// For less clutter in the SSCCE
20-
timestamps: false,
21-
},
2218
});
2319

2420
class Foo extends Model {}
2521

2622
Foo.init({
27-
name: DataTypes.TEXT,
23+
id: {
24+
type: DataTypes.UUID,
25+
defaultValue: DataTypes.UUIDV4,
26+
primaryKey: true
27+
},
2828
}, {
2929
sequelize,
3030
modelName: 'Foo',
@@ -36,6 +36,9 @@ export async function run() {
3636
await sequelize.sync({ force: true });
3737
expect(spy).to.have.been.called;
3838

39-
console.log(await Foo.create({ name: 'TS foo' }));
39+
expect(Foo.bulkCreate(
40+
[{ id: 'e8388762-1daa-11ef-b9f0-b7d47c40e7e3' }],
41+
{ updateOnDuplicate: ['createdAt'] }
42+
)).to.not.be.rejected;
4043
expect(await Foo.count()).to.equal(1);
4144
}

0 commit comments

Comments
 (0)