From aa5c08d5649a40eb2b15f38cd31f8d08b59b9f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=AE=97=E6=B4=8B?= Date: Thu, 6 Jul 2023 11:06:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=B2=98=E8=BF=9E=E6=97=A0=E6=B3=95=E6=8F=90=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mayfly_go_web/src/views/ops/db/SqlExec.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mayfly_go_web/src/views/ops/db/SqlExec.vue b/mayfly_go_web/src/views/ops/db/SqlExec.vue index 5acaf5e8..f4e9e7d7 100644 --- a/mayfly_go_web/src/views/ops/db/SqlExec.vue +++ b/mayfly_go_web/src/views/ops/db/SqlExec.vue @@ -491,7 +491,7 @@ const registerSqlCompletionItemProvider = () => { // // const nextTokens = textAfterPointer.trim().split(/\s+/) // // const nextToken = nextTokens[0].toLowerCase() const tokens = textBeforePointer.trim().split(/\s+/) - const lastToken = tokens[tokens.length - 1].toLowerCase() + let lastToken = tokens[tokens.length - 1].toLowerCase() const secondToken = tokens.length > 2 && tokens[tokens.length - 2].toLowerCase() || '' // const dbs = nowTab.params?.dbs?.split(' ') || []; @@ -531,7 +531,15 @@ const registerSqlCompletionItemProvider = () => { if (lastToken.trim().startsWith('.')) { str = secondToken } - + // 如果字符串粘连起了如:'a.creator,a.',需要重新取出别名 + let aliasArr = lastToken.split(','); + if (aliasArr.length > 1){ + lastToken = aliasArr[aliasArr.length-1]; + str = lastToken.substring(0, lastToken.lastIndexOf('.')) + if (lastToken.trim().startsWith('.')) { + str = secondToken + } + } // 库.表名联想 if (dbs && dbs.filter((a: any) => a === str)?.length > 0) { let tables = await dbInst.loadTables(str)