@@ -217,32 +217,41 @@ export function useChenQueryConsole(
217217 }
218218 }
219219
220- function runQueryTab ( tab : ChenQueryConsoleTab , selectedSql = "" ) {
221- if ( tab . state . loading || tab . state . inQuery ) return ;
222- const sql = selectedSql || tab . statement ;
223- if ( ! sql . trim ( ) ) return ;
224- dismissQueryMessage ( tab ) ;
225-
220+ function sendSql ( tab : ChenQueryLikeWorkspaceTab , sql : string ) {
226221 if ( sql . length <= SQL_CHUNK_SIZE ) {
227- sendConsoleAction ( tab , "query_console_action" , { action : "run_sql" , data : sql } ) ;
228- return ;
222+ return sendConsoleAction ( tab , "query_console_action" , { action : "run_sql" , data : sql } ) !== false ;
229223 }
230224
231225 const total = Math . ceil ( sql . length / SQL_CHUNK_SIZE ) ;
232226 for ( let index = 0 ; index < total ; index += 1 ) {
233- sendConsoleAction ( tab , "query_console_action" , {
234- action : "run_sql_chunk" ,
235- data : {
236- chunk : sql . slice ( index * SQL_CHUNK_SIZE , ( index + 1 ) * SQL_CHUNK_SIZE ) ,
237- index,
238- total
239- }
240- } ) ;
227+ if (
228+ sendConsoleAction ( tab , "query_console_action" , {
229+ action : "run_sql_chunk" ,
230+ data : {
231+ chunk : sql . slice ( index * SQL_CHUNK_SIZE , ( index + 1 ) * SQL_CHUNK_SIZE ) ,
232+ index,
233+ total
234+ }
235+ } ) === false
236+ ) {
237+ return false ;
238+ }
241239 }
242- sendConsoleAction ( tab , "query_console_action" , {
243- action : "run_sql_complete" ,
244- data : { total }
245- } ) ;
240+ return (
241+ sendConsoleAction ( tab , "query_console_action" , {
242+ action : "run_sql_complete" ,
243+ data : { total }
244+ } ) !== false
245+ ) ;
246+ }
247+
248+ function runQueryTab ( tab : ChenQueryConsoleTab , selectedSql = "" ) {
249+ if ( tab . state . loading || tab . state . inQuery ) return ;
250+ const sql = selectedSql || tab . statement ;
251+ if ( ! sql . trim ( ) ) return ;
252+ dismissQueryMessage ( tab ) ;
253+
254+ sendSql ( tab , sql ) ;
246255 }
247256
248257 function runQueryFile ( tab : ChenQueryConsoleTab , path : string ) {
@@ -296,8 +305,7 @@ export function useChenQueryConsole(
296305 tab . timelineEntries . splice ( 0 , tab . timelineEntries . length - MAX_CONSOLE_TIMELINE_ENTRIES ) ;
297306 }
298307 tab . activeTimelineEntryId = entry . id ;
299- const sent = sendConsoleAction ( tab , "query_console_action" , { action : "run_sql" , data : sql } ) ;
300- if ( sent === false ) {
308+ if ( ! sendSql ( tab , sql ) ) {
301309 entry . status = "error" ;
302310 entry . completedAt = Date . now ( ) ;
303311 const message = tab . connectionError || "Console websocket is not connected" ;
0 commit comments