From d317fa056a826310e52bf3ccbdb4e998f8e3bba5 Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Sun, 1 Jan 2023 23:15:08 +0800 Subject: [PATCH] chore: set belongs to many on delete to cascade (#1311) --- packages/core/database/src/fields/belongs-to-many-field.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/database/src/fields/belongs-to-many-field.ts b/packages/core/database/src/fields/belongs-to-many-field.ts index e7fed468c..dab447c7a 100644 --- a/packages/core/database/src/fields/belongs-to-many-field.ts +++ b/packages/core/database/src/fields/belongs-to-many-field.ts @@ -30,9 +30,11 @@ export class BelongsToManyField extends RelationField { references(association): Reference[] { const db = this.context.database; + const onDelete = this.options.onDelete || 'CASCADE'; + return [ - BelongsToField.toReference(db, association.toSource, this.options.onDelete), - BelongsToField.toReference(db, association.toTarget, this.options.onDelete), + BelongsToField.toReference(db, association.toSource, onDelete), + BelongsToField.toReference(db, association.toTarget, onDelete), ]; }