diff --git a/package.json b/package.json index 7b085ecf8..9afb90e05 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,15 @@ "type": "commonjs", "license": "MIT", "dependencies": { + "@sequelize/core": "^7.0.0-alpha.10", "chai": "^4", "chai-as-promised": "^7", "chai-datetime": "^1", "chalk": "^4.1.2", "cross-env": "^7", "fs-jetpack": "^4", + "mysql2": "^3.3.0", "sequelize": "^6", - "@sequelize/core": "^7.0.0-alpha.10", "sinon": "^13", "sinon-chai": "^3" }, diff --git a/src/sscce-sequelize-6.ts b/src/sscce-sequelize-6.ts deleted file mode 100644 index c90761b96..000000000 --- a/src/sscce-sequelize-6.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { DataTypes, Model } from 'sequelize'; -import { createSequelize6Instance } from '../setup/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']); - -// You can delete this file if you don't want your SSCCE to be tested against Sequelize 6 - -// Your SSCCE goes inside this function. -export async function run() { - // This function should be used instead of `new Sequelize()`. - // It applies the config for your SSCCE to work on CI. - 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, - }, { - sequelize, - modelName: 'Foo', - }); - - // 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); -} diff --git a/src/sscce-sequelize-7.ts b/src/sscce-sequelize-7.ts index 861b9fdea..da30ba895 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 '../setup/create-sequelize-instance'; -import { expect } from 'chai'; -import sinon from 'sinon'; +import { DataTypes, Model } from "@sequelize/core"; +import { createSequelize7Instance } from "../setup/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 @@ -21,13 +28,38 @@ export async function run() { }, }); - class Foo extends Model {} + const Action = sequelize.define("Action", {}, { tableName: "Action" }); + const ActionGoto = sequelize.define("Action_Goto", {}); - Foo.init({ - name: DataTypes.TEXT, - }, { - sequelize, - modelName: 'Foo', + Action.hasOne(ActionGoto, { + as: "Goto", + foreignKey: { + name: "ActionId", + onDelete: "CASCADE", + onUpdate: "CASCADE", + }, + }); + Action.hasOne(ActionGoto, { + foreignKey: { + name: "TargetActionId", + onDelete: "CASCADE", + onUpdate: "CASCADE", + }, + }); + + ActionGoto.belongsTo(Action, { + foreignKey: { + name: "ActionId", + onDelete: "CASCADE", + onUpdate: "CASCADE", + }, + }); + ActionGoto.belongsTo(Action, { + foreignKey: { + name: "TargetActionId", + onDelete: "CASCADE", + onUpdate: "CASCADE", + }, }); // You can use sinon and chai assertions directly in your SSCCE. @@ -35,7 +67,4 @@ export async function run() { 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); }