From 2eff8f26b0eee7f7519140b9d04896e8250ebd9f Mon Sep 17 00:00:00 2001 From: speexy Date: Thu, 20 Jul 2023 12:19:41 +0200 Subject: [PATCH 1/4] Update sscce-sequelize-7.ts check if passwords are returned --- src/sscce-sequelize-7.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/sscce-sequelize-7.ts b/src/sscce-sequelize-7.ts index 861b9fdea..8f4082874 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 @@ -23,11 +23,12 @@ export async function run() { class Foo 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,17 @@ 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}); + 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}); + expect(updatedWithChange.name).to.equal('Bar'); + expect(updatedWithChange.password).to.be.undefined; + const updatedNoChange = await User.update({name:undefined}, {where: {id: created.id}, returning: attributes}); + expect(updatedWithChange.name).to.equal('Bar'); + expect(updatedWithChange.password).to.be.undefined; + + //expect(await Foo.count()).to.equal(1); + await User.up } From bd2e649b720f614d93b80b3662d2e8d8b5d7d78c Mon Sep 17 00:00:00 2001 From: speexy Date: Thu, 20 Jul 2023 12:25:30 +0200 Subject: [PATCH 2/4] Update sscce-sequelize-7.ts fix model name --- src/sscce-sequelize-7.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sscce-sequelize-7.ts b/src/sscce-sequelize-7.ts index 8f4082874..0a5bdfc9f 100644 --- a/src/sscce-sequelize-7.ts +++ b/src/sscce-sequelize-7.ts @@ -21,7 +21,7 @@ export async function run() { }, }); - class Foo extends Model {} + class User extends Model {} User.init({ name: DataTypes.STRING, From 17a9932d1a0ceb3a0f623bcf71d377c7eabb5b6c Mon Sep 17 00:00:00 2001 From: speexy Date: Thu, 20 Jul 2023 12:42:56 +0200 Subject: [PATCH 3/4] Update sscce-sequelize-7.ts add console.logs --- src/sscce-sequelize-7.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sscce-sequelize-7.ts b/src/sscce-sequelize-7.ts index 0a5bdfc9f..6d611d10a 100644 --- a/src/sscce-sequelize-7.ts +++ b/src/sscce-sequelize-7.ts @@ -39,12 +39,15 @@ export async function run() { 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}); + console.log(updatedWithChange) expect(updatedWithChange.name).to.equal('Bar'); expect(updatedWithChange.password).to.be.undefined; const updatedNoChange = await User.update({name:undefined}, {where: {id: created.id}, returning: attributes}); + console.log(updatedNoChange) expect(updatedWithChange.name).to.equal('Bar'); expect(updatedWithChange.password).to.be.undefined; From 67951ebfbee09b1c5779d6a76f57c262e2be5506 Mon Sep 17 00:00:00 2001 From: speexy Date: Thu, 20 Jul 2023 17:08:32 +0200 Subject: [PATCH 4/4] Update sscce-sequelize-7.ts get correct part of update response and add individualHooks option --- src/sscce-sequelize-7.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sscce-sequelize-7.ts b/src/sscce-sequelize-7.ts index 6d611d10a..f0a16cac4 100644 --- a/src/sscce-sequelize-7.ts +++ b/src/sscce-sequelize-7.ts @@ -42,14 +42,14 @@ export async function run() { 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}); + const updatedWithChange = await User.update({name:'Bar'}, {where: {id: created.id}, returning: attributes, individualHooks: true}); console.log(updatedWithChange) - expect(updatedWithChange.name).to.equal('Bar'); - expect(updatedWithChange.password).to.be.undefined; - const updatedNoChange = await User.update({name:undefined}, {where: {id: created.id}, returning: attributes}); + 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.name).to.equal('Bar'); - expect(updatedWithChange.password).to.be.undefined; + 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