From 1aa2cb0aa43d9f7a2bba3e8f814545a0f9d845b1 Mon Sep 17 00:00:00 2001 From: Imiss-U1025 Date: Mon, 10 Feb 2025 00:52:10 -0500 Subject: [PATCH 1/4] check variable name duplication when duplicating the query --- .../lowcoder/src/comps/queries/queryComp.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/packages/lowcoder/src/comps/queries/queryComp.tsx b/client/packages/lowcoder/src/comps/queries/queryComp.tsx index 92a33e7b6..86e582ed0 100644 --- a/client/packages/lowcoder/src/comps/queries/queryComp.tsx +++ b/client/packages/lowcoder/src/comps/queries/queryComp.tsx @@ -773,12 +773,24 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp { if (!originQuery) { return; } + + const jsonData = originQuery.toJsonValue(); + //Regenerate variable header + jsonData.variables?.variables?.forEach(kv => { + const [prefix, _] = (kv.key as string).split(/(?=\d+$)/); + let i=2, newName = ""; + do { + newName = prefix + (i++); + } while(editorState.checkRename("", newName)); + kv.key = newName; + }) + const newQueryName = this.genNewName(editorState); const id = genQueryId(); this.dispatch( wrapActionExtraInfo( this.pushAction({ - ...originQuery.toJsonValue(), + ...jsonData, id: id, name: newQueryName, isNewCreate: true, @@ -789,7 +801,7 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp { { type: "add", compName: name, - compType: originQuery.children.compType.getView(), + compType: jsonData.compType, }, ], } From 353baf2c1084a8a8de1ee16b03b33fc7b543d146 Mon Sep 17 00:00:00 2001 From: Imiss-U1025 Date: Mon, 10 Feb 2025 01:01:43 -0500 Subject: [PATCH 2/4] show variables in left panel --- client/packages/lowcoder/src/comps/queries/queryComp.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/packages/lowcoder/src/comps/queries/queryComp.tsx b/client/packages/lowcoder/src/comps/queries/queryComp.tsx index 86e582ed0..fb1462b84 100644 --- a/client/packages/lowcoder/src/comps/queries/queryComp.tsx +++ b/client/packages/lowcoder/src/comps/queries/queryComp.tsx @@ -673,8 +673,8 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [ return undefined; } const newNode = Object.values(input.data) - .filter((kvNode: any) => kvNode.key.value) - .map((kvNode: any) => ({[kvNode.key.value]: kvNode.value.value})) + .filter((kvNode: any) => kvNode.key) + .map((kvNode: any) => ({[kvNode.key]: kvNode.value})) .reduce((prev, obj) => ({...prev, ...obj}), {}); return newNode; }, From 424f429c9fec5514ce2f28fec6ff331b741e714f Mon Sep 17 00:00:00 2001 From: Imiss-U1025 Date: Mon, 10 Feb 2025 01:04:01 -0500 Subject: [PATCH 3/4] start from suffix number 1 --- client/packages/lowcoder/src/comps/queries/queryComp.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/packages/lowcoder/src/comps/queries/queryComp.tsx b/client/packages/lowcoder/src/comps/queries/queryComp.tsx index fb1462b84..a9c1b5bf7 100644 --- a/client/packages/lowcoder/src/comps/queries/queryComp.tsx +++ b/client/packages/lowcoder/src/comps/queries/queryComp.tsx @@ -778,7 +778,7 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp { //Regenerate variable header jsonData.variables?.variables?.forEach(kv => { const [prefix, _] = (kv.key as string).split(/(?=\d+$)/); - let i=2, newName = ""; + let i=1, newName = ""; do { newName = prefix + (i++); } while(editorState.checkRename("", newName)); From 6786b8ea807b61727cf12b1b8512dcd864d61120 Mon Sep 17 00:00:00 2001 From: Imiss-U1025 Date: Mon, 10 Feb 2025 01:54:54 -0500 Subject: [PATCH 4/4] variable override issue fixed --- .../controls/actionSelector/executeQueryAction.tsx | 12 +++++------- .../lowcoder/src/comps/queries/queryComp.tsx | 1 + .../lowcoder/src/comps/queries/queryCompUtils.tsx | 3 ++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx b/client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx index 4de200bda..5febe82ff 100644 --- a/client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx +++ b/client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx @@ -112,14 +112,12 @@ export class ExecuteQueryAction extends ExecuteQueryTmpAction { override getView() { const queryName = this.children.queryName.getView(); // const queryParams = keyValueListToSearchStr(Array.isArray(this?.children?.query) ? (this.children.query as unknown as any[]).map((i: any) => i.getView() as KeyValue) : []); - const result = Object.values(this.children.queryVariables.children as Record) - .filter(item => item.children.key.unevaledValue !== "" && item.children.value.unevaledValue !== "") - .map(item => ({[item.children.key.unevaledValue]: item.children.value.unevaledValue})) + const result = this.children.queryVariables.toJsonValue() + .filter(item => item.key !== "" && item.value !== "") + .map(item => ({[item.key as string]: item.value})) .reduce((acc, curr) => Object.assign(acc, curr), {}); + + result.$queryName = queryName; if (!queryName) { return () => Promise.resolve(); } diff --git a/client/packages/lowcoder/src/comps/queries/queryComp.tsx b/client/packages/lowcoder/src/comps/queries/queryComp.tsx index a9c1b5bf7..066b351fe 100644 --- a/client/packages/lowcoder/src/comps/queries/queryComp.tsx +++ b/client/packages/lowcoder/src/comps/queries/queryComp.tsx @@ -364,6 +364,7 @@ QueryCompTmp = class extends QueryCompTmp { if (action.type === CompActionTypes.EXECUTE_QUERY) { if (getReduceContext().disableUpdateState) return this; if(!action.args) action.args = this.children.variables.children.variables.toJsonValue().reduce((acc, curr) => Object.assign(acc, {[curr.key as string]:curr.value}), {}); + action.args.$queryName = this.children.name.getView(); return this.executeQuery(action); } diff --git a/client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx b/client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx index 1203e1cfd..d319689e7 100644 --- a/client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx +++ b/client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx @@ -28,9 +28,10 @@ export function toQueryView(params: FunctionProperty[]) { variables?: any; timeout: InstanceType; }): Promise => { + console.log("toQueryView props", props, params); const { applicationId, isViewMode } = getGlobalSettings(); - const mappedVariables = Object.keys(props.variables).map(key => ({key: `query1.variable.${key}`, value: props.variables[key]})); + const mappedVariables = Object.keys(props.variables).map(key => ({key: `${props.args?.$queryName}.variables.${key}`, value: props.variables[key]})); let request: QueryExecuteRequest = { path: props.applicationPath, params: [ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy