From 07a856d4f847dce63b0562c976900758f8822c6a Mon Sep 17 00:00:00 2001 From: popcorny Date: Thu, 7 Mar 2024 18:02:32 +0800 Subject: [PATCH] Fix the default pk issue Signed-off-by: popcorny --- js/src/components/valuediff/ValueDiffForm.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/src/components/valuediff/ValueDiffForm.tsx b/js/src/components/valuediff/ValueDiffForm.tsx index b38cb346..bc3edaa8 100644 --- a/js/src/components/valuediff/ValueDiffForm.tsx +++ b/js/src/components/valuediff/ValueDiffForm.tsx @@ -76,10 +76,20 @@ export function ValueDiffForm({ ); const model = params?.model; + const primaryKey = params?.primary_key; const node = _.find(lineageGraph.lineageGraphSets?.all.nodes, { name: params?.model, }); - const primaryKey = params?.primary_key || node?.data.current?.primary_key; + const nodePrimaryKey = node?.data.current?.primary_key; + + useEffect(() => { + if (!primaryKey && nodePrimaryKey) { + onParamsChanged({ + ...params, + primary_key: nodePrimaryKey, + }); + } + }, [primaryKey, nodePrimaryKey, params, onParamsChanged]); useEffect(() => { setIsReadyToExecute(primaryKey && model ? true : false);