diff --git a/src/sscce-sequelize-7.ts b/src/sscce-sequelize-7.ts index 861b9fdea..f0a16cac4 100644 --- a/src/sscce-sequelize-7.ts +++ b/src/sscce-sequelize-7.ts @@ -4,7 +4,7 @@ import { expect } from 'chai'; import sinon from 'sinon'; // if your issue is dialect specific, remove the dialects you don't need to test on. -export const testingOnDialects = new Set(['mssql', 'sqlite', 'mysql', 'mariadb', 'postgres', 'postgres-native']); +export const testingOnDialects = new Set([ 'postgres', 'postgres-native']); // You can delete this file if you don't want your SSCCE to be tested against Sequelize 7 @@ -21,13 +21,14 @@ export async function run() { }, }); - class Foo extends Model {} + class User extends Model {} - Foo.init({ - name: DataTypes.TEXT, + User.init({ + name: DataTypes.STRING, + password: DataTypes.STRING }, { sequelize, - modelName: 'Foo', + modelName: 'User', }); // You can use sinon and chai assertions directly in your SSCCE. @@ -36,6 +37,20 @@ export async function run() { await sequelize.sync({ force: true }); expect(spy).to.have.been.called; - console.log(await Foo.create({ name: 'TS foo' })); - expect(await Foo.count()).to.equal(1); + const attributes = ['name']; + const created = await User.create({ name: 'Foo', password: 'pass' }, {returning: attributes}); + console.log(created); + expect(created.name).to.equal('Foo); + expect(created.password).to.be.undefined; + const updatedWithChange = await User.update({name:'Bar'}, {where: {id: created.id}, returning: attributes, individualHooks: true}); + console.log(updatedWithChange) + expect(updatedWithChange[1][0].name).to.equal('Bar'); + expect(updatedWithChange[1][0].password).to.be.undefined; + const updatedNoChange = await User.update({name:undefined}, {where: {id: created.id}, returning: attributes, individualHooks: true}); + console.log(updatedNoChange) + expect(updatedWithChange[1][0].name).to.equal('Bar'); + expect(updatedWithChange[1][0].password).to.be.undefined; + + //expect(await Foo.count()).to.equal(1); + await User.up }