Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit42a8018

Browse files
authored
Merge pull request#1516 from lowcoder-org/fix/global_unique_variable_name
implemented uniqueness of variable name among editorState, queries (including query duplication)
2 parentsfe3eddd +6786b8e commit42a8018

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

‎client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,12 @@ export class ExecuteQueryAction extends ExecuteQueryTmpAction {
112112
overridegetView(){
113113
constqueryName=this.children.queryName.getView();
114114
// const queryParams = keyValueListToSearchStr(Array.isArray(this?.children?.query) ? (this.children.query as unknown as any[]).map((i: any) => i.getView() as KeyValue) : []);
115-
constresult=Object.values(this.children.queryVariables.childrenasRecord<string,{
116-
children:{
117-
key:{unevaledValue:string},
118-
value:{unevaledValue:string}
119-
}}>)
120-
.filter(item=>item.children.key.unevaledValue!==""&&item.children.value.unevaledValue!=="")
121-
.map(item=>({[item.children.key.unevaledValue]:item.children.value.unevaledValue}))
115+
constresult=this.children.queryVariables.toJsonValue()
116+
.filter(item=>item.key!==""&&item.value!=="")
117+
.map(item=>({[item.keyasstring]:item.value}))
122118
.reduce((acc,curr)=>Object.assign(acc,curr),{});
119+
120+
result.$queryName=queryName;
123121
if(!queryName){
124122
return()=>Promise.resolve();
125123
}

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ QueryCompTmp = class extends QueryCompTmp {
364364
if(action.type===CompActionTypes.EXECUTE_QUERY){
365365
if(getReduceContext().disableUpdateState)returnthis;
366366
if(!action.args)action.args=this.children.variables.children.variables.toJsonValue().reduce((acc,curr)=>Object.assign(acc,{[curr.keyasstring]:curr.value}),{});
367+
action.args.$queryName=this.children.name.getView();
367368

368369
returnthis.executeQuery(action);
369370
}
@@ -673,8 +674,8 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
673674
returnundefined;
674675
}
675676
constnewNode=Object.values(input.data)
676-
.filter((kvNode:any)=>kvNode.key.value)
677-
.map((kvNode:any)=>({[kvNode.key.value]:kvNode.value.value}))
677+
.filter((kvNode:any)=>kvNode.key)
678+
.map((kvNode:any)=>({[kvNode.key]:kvNode.value}))
678679
.reduce((prev,obj)=>({...prev, ...obj}),{});
679680
returnnewNode;
680681
},
@@ -773,12 +774,24 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
773774
if(!originQuery){
774775
return;
775776
}
777+
778+
constjsonData=originQuery.toJsonValue();
779+
//Regenerate variable header
780+
jsonData.variables?.variables?.forEach(kv=>{
781+
const[prefix,_]=(kv.keyasstring).split(/(?=\d+$)/);
782+
leti=1,newName="";
783+
do{
784+
newName=prefix+(i++);
785+
}while(editorState.checkRename("",newName));
786+
kv.key=newName;
787+
})
788+
776789
constnewQueryName=this.genNewName(editorState);
777790
constid=genQueryId();
778791
this.dispatch(
779792
wrapActionExtraInfo(
780793
this.pushAction({
781-
...originQuery.toJsonValue(),
794+
...jsonData,
782795
id:id,
783796
name:newQueryName,
784797
isNewCreate:true,
@@ -789,7 +802,7 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
789802
{
790803
type:"add",
791804
compName:name,
792-
compType:originQuery.children.compType.getView(),
805+
compType:jsonData.compType,
793806
},
794807
],
795808
}

‎client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ export function toQueryView(params: FunctionProperty[]) {
2828
variables?:any;
2929
timeout:InstanceType<ParamsControlType>;
3030
}):Promise<QueryResult>=>{
31+
console.log("toQueryView props",props,params);
3132
const{ applicationId, isViewMode}=getGlobalSettings();
3233

33-
constmappedVariables=Object.keys(props.variables).map(key=>({key:`query1.variable.${key}`,value:props.variables[key]}));
34+
constmappedVariables=Object.keys(props.variables).map(key=>({key:`${props.args?.$queryName}.variables.${key}`,value:props.variables[key]}));
3435
letrequest:QueryExecuteRequest={
3536
path:props.applicationPath,
3637
params:[

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp