From 57abdd1a3e390f9d0c94885098df620fc687eced Mon Sep 17 00:00:00 2001 From: Kwaay Date: Sun, 3 Mar 2024 19:56:20 +0100 Subject: [PATCH] Add Bug Demo --- src/sscce-sequelize-7.ts | 58 ++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/src/sscce-sequelize-7.ts b/src/sscce-sequelize-7.ts index 4a5757700..a84072ac6 100644 --- a/src/sscce-sequelize-7.ts +++ b/src/sscce-sequelize-7.ts @@ -1,10 +1,17 @@ -import { DataTypes, Model } from '@sequelize/core'; -import { createSequelize7Instance } from '../dev/create-sequelize-instance'; -import { expect } from 'chai'; -import sinon from 'sinon'; +import { DataTypes, Model } from "@sequelize/core"; +import { createSequelize7Instance } from "../dev/create-sequelize-instance"; +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([ + // "mssql", + "sqlite", + // "mysql", + // "mariadb", + // "postgres", + // "postgres-native", +]); // You can delete this file if you don't want your SSCCE to be tested against Sequelize 7 @@ -22,20 +29,43 @@ export async function run() { }); class Foo extends Model {} + class Bar extends Model {} - Foo.init({ - name: DataTypes.TEXT, - }, { - sequelize, - modelName: 'Foo', - }); + Foo.init( + { + name: DataTypes.TEXT, + }, + { + sequelize, + modelName: "Foo", + } + ); + + Bar.init( + { + name: DataTypes.TEXT, + }, + { + sequelize, + modelName: "BAR", + } + ); + + Bar.belongsTo(Foo); + Foo.hasMany(Bar); // You can use sinon and chai assertions directly in your SSCCE. const spy = sinon.spy(); sequelize.afterBulkSync(() => spy()); 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); + await Foo.create({ name: "TS foo" }); + await Bar.create({ name: "Bar1", FooId: 1 }); + await Bar.create({ name: "Bar2", FooId: 1 }); + + const data = await Foo.findAll({ + include: { all: true }, + }); + + expect(Object.keys(data).includes("BARs")).to.be.true; }