Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💩 Add bug demonstration #254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
41 changes: 0 additions & 41 deletions src/sscce-sequelize-6.ts

This file was deleted.

57 changes: 43 additions & 14 deletions src/sscce-sequelize-7.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -21,21 +28,43 @@ 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.
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);
}