fix(database): constraints default to false (#550)

* fix(database): constraints default to false

* test(plugin-workflow): skip schedule cases

Co-authored-by: mytharcher <mytharcher@gmail.com>
This commit is contained in:
chenos 2022-06-29 23:20:00 +08:00 committed by GitHub
parent 017c6f232d
commit d3b157075e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

View File

@ -28,6 +28,7 @@ export class BelongsToField extends RelationField {
// define relation on sequelize model // define relation on sequelize model
const association = collection.model.belongsTo(Target, { const association = collection.model.belongsTo(Target, {
as: this.name, as: this.name,
constraints: false,
...omit(this.options, ['name', 'type', 'target']), ...omit(this.options, ['name', 'type', 'target']),
}); });

View File

@ -37,6 +37,7 @@ export class BelongsToManyField extends RelationField {
} }
const association = collection.model.belongsToMany(Target, { const association = collection.model.belongsToMany(Target, {
constraints: false,
...omit(this.options, ['name', 'type', 'target']), ...omit(this.options, ['name', 'type', 'target']),
as: this.name, as: this.name,
through: Through.model, through: Through.model,

View File

@ -5,10 +5,10 @@ import {
ForeignKeyOptions, ForeignKeyOptions,
HasManyOptions, HasManyOptions,
HasManyOptions as SequelizeHasManyOptions, HasManyOptions as SequelizeHasManyOptions,
Utils, Utils
} from 'sequelize'; } from 'sequelize';
import { BaseRelationFieldOptions, MultipleRelationFieldOptions, RelationField } from './relation-field'; import { MultipleRelationFieldOptions, RelationField } from './relation-field';
export interface HasManyFieldOptions extends HasManyOptions { export interface HasManyFieldOptions extends HasManyOptions {
/** /**
@ -93,9 +93,10 @@ export class HasManyField extends RelationField {
} }
const association = collection.model.hasMany(Target, { const association = collection.model.hasMany(Target, {
constraints: false,
...omit(this.options, ['name', 'type', 'target']),
as: this.name, as: this.name,
foreignKey: this.foreignKey, foreignKey: this.foreignKey,
...omit(this.options, ['name', 'type', 'target']),
}); });
// inverse relation // inverse relation

View File

@ -92,9 +92,10 @@ export class HasOneField extends RelationField {
return false; return false;
} }
const association = collection.model.hasOne(Target, { const association = collection.model.hasOne(Target, {
constraints: false,
...omit(this.options, ['name', 'type', 'target']),
as: this.name, as: this.name,
foreignKey: this.foreignKey, foreignKey: this.foreignKey,
...omit(this.options, ['name', 'type', 'target']),
}); });
// 建立关系之后从 pending 列表中删除 // 建立关系之后从 pending 列表中删除
database.removePendingField(this); database.removePendingField(this);