Skip to content

Commit 1aa2cb0

Browse files
committed
check variable name duplication when duplicating the query
1 parent 041aef5 commit 1aa2cb0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

client/packages/lowcoder/src/comps/queries/queryComp.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,12 +773,24 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
773773
if (!originQuery) {
774774
return;
775775
}
776+
777+
const jsonData = originQuery.toJsonValue();
778+
//Regenerate variable header
779+
jsonData.variables?.variables?.forEach(kv => {
780+
const [prefix, _] = (kv.key as string).split(/(?=\d+$)/);
781+
let i=2, newName = "";
782+
do {
783+
newName = prefix + (i++);
784+
} while(editorState.checkRename("", newName));
785+
kv.key = newName;
786+
})
787+
776788
const newQueryName = this.genNewName(editorState);
777789
const id = genQueryId();
778790
this.dispatch(
779791
wrapActionExtraInfo(
780792
this.pushAction({
781-
...originQuery.toJsonValue(),
793+
...jsonData,
782794
id: id,
783795
name: newQueryName,
784796
isNewCreate: true,
@@ -789,7 +801,7 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
789801
{
790802
type: "add",
791803
compName: name,
792-
compType: originQuery.children.compType.getView(),
804+
compType: jsonData.compType,
793805
},
794806
],
795807
}

0 commit comments

Comments
 (0)
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