Skip to content

Commit c14741b

Browse files
authored
Merge pull request #1524 from lowcoder-org/fix/global_unique_variable_name
Check for uniqueness of variable name within new cloned query
2 parents 0cd9490 + 917880e commit c14741b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -777,13 +777,15 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
777777

778778
const jsonData = originQuery.toJsonValue();
779779
//Regenerate variable header
780+
const newKeys:string[] = [];
780781
jsonData.variables?.variables?.forEach(kv => {
781782
const [prefix, _] = (kv.key as string).split(/(?=\d+$)/);
782783
let i=1, newName = "";
783784
do {
784785
newName = prefix + (i++);
785-
} while(editorState.checkRename("", newName));
786+
} while(editorState.checkRename("", newName) || newKeys.includes(newName));
786787
kv.key = newName;
788+
newKeys.push(newName);
787789
})
788790

789791
const newQueryName = this.genNewName(editorState);

0 commit comments

Comments
 (0)