From 2195a31f5b8f590a82394d57ba0c2dcc5312066b Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Mon, 25 Mar 2024 16:02:52 +0800 Subject: [PATCH] chore: cascade can replace set null action (#3812) --- .../core/database/src/features/references-map.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/core/database/src/features/references-map.ts b/packages/core/database/src/features/references-map.ts index a78c6b95c..0f961a457 100644 --- a/packages/core/database/src/features/references-map.ts +++ b/packages/core/database/src/features/references-map.ts @@ -52,11 +52,15 @@ class ReferencesMap { existReference.onDelete = reference.onDelete; existReference.priority = reference.priority; } else if (newPriority === existPriority && newPriority === PRIORITY_MAP['user']) { - throw new Error( - `On Delete Conflict, exist reference ${JSON.stringify(existReference)}, new reference ${JSON.stringify( - reference, - )}`, - ); + if (existReference.onDelete === 'SET NULL' && reference.onDelete === 'CASCADE') { + existReference.onDelete = reference.onDelete; + } else { + throw new Error( + `On Delete Conflict, exist reference ${JSON.stringify(existReference)}, new reference ${JSON.stringify( + reference, + )}`, + ); + } } }