@@ -161,12 +161,15 @@ export class MetabaseController extends AppController<MetabaseAppState> {
161161 return { text : `Using ${ Object . keys ( template_tags || { } ) . length } template tags and ${ ( parameters || [ ] ) . length } parameters` , code : sql , oldCode : sqlQuery }
162162 }
163163 } )
164- async updateSQLQueryWithParams ( { sql, template_tags = { } , parameters = [ ] , parameterValues = [ ] , executeImmediately = true , _type = "markdown" , ctes = [ ] } : { sql : string , template_tags ?: object , parameters ?: any [ ] , parameterValues ?: Array < { id : string , value : string [ ] } > , executeImmediately ?: boolean , _type ?: string , ctes : CTE [ ] } ) {
164+ async updateSQLQueryWithParams ( { sql, template_tags = { } , parameters = [ ] , parameterValues = [ ] , executeImmediately = true , _type = "markdown" , ctes = [ ] , skipConfirmation = false } : { sql : string , template_tags ?: object , parameters ?: any [ ] , parameterValues ?: Array < { id : string , value : string [ ] } > , executeImmediately ?: boolean , _type ?: string , ctes : CTE [ ] , skipConfirmation ?: boolean } ) {
165165 const actionContent : BlankMessageContent = {
166166 type : "BLANK" ,
167167 } ;
168168 const state = ( await this . app . getState ( ) ) as MetabaseAppStateSQLEditor ;
169- const { userApproved, userFeedback } = await RPCs . getUserConfirmation ( { content : sql , contentTitle : "Approve SQL Query?" , oldContent : state . currentCard ?. dataset_query ?. native ?. query || state . sqlQuery || '' } ) ;
169+ const oldContent = state . currentCard ?. dataset_query ?. native ?. query || state . sqlQuery || ''
170+ const isContentUnchanged = sql == oldContent
171+ const override = skipConfirmation || isContentUnchanged ? false : undefined
172+ const { userApproved, userFeedback } = await RPCs . getUserConfirmation ( { content : sql , contentTitle : "Approve SQL Query?" , oldContent, override} ) ;
170173 if ( ! userApproved ) {
171174 actionContent . content = '<UserCancelled>Reason: ' + ( userFeedback === '' ? 'No particular reason given' : userFeedback ) + '</UserCancelled>' ;
172175 return actionContent ;
@@ -411,7 +414,7 @@ export class MetabaseController extends AppController<MetabaseAppState> {
411414 return { text : `${ explanation } ${ paramValuesInfo } ` , code : sql , oldCode : currentQuery , language : "sql" , extraArgs : { old : { template_tags : currentTemplateTags , parameters : currentParameters } , new : { template_tags, parameters, parameterValues} } }
412415 }
413416 } )
414- async ExecuteQuery ( { sql, _ctes = [ ] , explanation = "" , template_tags= { } , parameters= [ ] , parameterValues= [ ] } : { sql : string , _ctes ?: CTE [ ] , explanation ?: string , template_tags ?: object , parameters ?: any [ ] , parameterValues ?: Array < { id : string , value : string [ ] } > } ) {
417+ async ExecuteQuery ( { sql, _ctes = [ ] , explanation = "" , template_tags= { } , parameters= [ ] , parameterValues= [ ] , skipConfirmation = false } : { sql : string , _ctes ?: CTE [ ] , explanation ?: string , template_tags ?: object , parameters ?: any [ ] , parameterValues ?: Array < { id : string , value : string [ ] } > , skipConfirmation ?: boolean } ) {
415418 // console.log('Template tags are', template_tags)
416419 // console.log('Parameters are', parameters)
417420 // Try parsing template_tags and parameters if they are strings
@@ -440,7 +443,7 @@ export class MetabaseController extends AppController<MetabaseAppState> {
440443 const pageType = metabaseState . useStore ( ) . getState ( ) . toolContext ?. pageType ;
441444
442445 if ( pageType === 'sql' ) {
443- return await this . updateSQLQueryWithParams ( { sql, template_tags, parameters, parameterValues, executeImmediately : true , _type : "markdown" , ctes : _ctes } ) ;
446+ return await this . updateSQLQueryWithParams ( { sql, template_tags, parameters, parameterValues, executeImmediately : true , _type : "markdown" , ctes : _ctes , skipConfirmation } ) ;
444447 }
445448 else if ( ( pageType === 'dashboard' ) || ( pageType === 'unknown' ) ) {
446449 return await this . runSQLQueryWithParams ( { sql, template_tags, parameters, ctes : _ctes } ) ;
0 commit comments