@@ -364,6 +364,7 @@ QueryCompTmp = class extends QueryCompTmp {
364364 if ( action . type === CompActionTypes . EXECUTE_QUERY ) {
365365 if ( getReduceContext ( ) . disableUpdateState ) return this ;
366366 if ( ! action . args ) action . args = this . children . variables . children . variables . toJsonValue ( ) . reduce ( ( acc , curr ) => Object . assign ( acc , { [ curr . key as string ] :curr . value } ) , { } ) ;
367+ action . args . $queryName = this . children . name . getView ( ) ;
367368
368369 return this . executeQuery ( action ) ;
369370 }
@@ -673,8 +674,8 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
673674 return undefined ;
674675 }
675676 const newNode = 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 return newNode ;
680681 } ,
@@ -773,12 +774,24 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
773774 if ( ! originQuery ) {
774775 return ;
775776 }
777+
778+ const jsonData = originQuery . toJsonValue ( ) ;
779+ //Regenerate variable header
780+ jsonData . variables ?. variables ?. forEach ( kv => {
781+ const [ prefix , _ ] = ( kv . key as string ) . split ( / (? = \d + $ ) / ) ;
782+ let i = 1 , newName = "" ;
783+ do {
784+ newName = prefix + ( i ++ ) ;
785+ } while ( editorState . checkRename ( "" , newName ) ) ;
786+ kv . key = newName ;
787+ } )
788+
776789 const newQueryName = this . genNewName ( editorState ) ;
777790 const id = 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 }
0 commit comments