mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-12 16:02:48 +08:00
🐛 fix(tdengine): 修复旧版 TDengine 元数据查询与驱动版本选择异常
- 放开 TDengine 已安装驱动的历史版本切换入口 - 兼容低版本 SHOW TABLES FROM 语法差异 - 修复表概览加载时报 [0x2600] syntax error near - 新增后端兼容与前端交互回归测试 - Close #531
This commit is contained in:
@@ -211,13 +211,7 @@ func (t *TDengineDB) GetDatabases() ([]string, error) {
|
||||
}
|
||||
|
||||
func (t *TDengineDB) GetTables(dbName string) ([]string, error) {
|
||||
queries := make([]string, 0, 4)
|
||||
if strings.TrimSpace(dbName) != "" {
|
||||
queries = append(queries, fmt.Sprintf("SHOW TABLES FROM `%s`", escapeBacktickIdent(dbName)))
|
||||
queries = append(queries, fmt.Sprintf("SHOW STABLES FROM `%s`", escapeBacktickIdent(dbName)))
|
||||
}
|
||||
queries = append(queries, "SHOW TABLES")
|
||||
queries = append(queries, "SHOW STABLES")
|
||||
queries := tdengineShowTablesQueries(dbName)
|
||||
|
||||
var lastErr error
|
||||
tableSet := make(map[string]struct{})
|
||||
@@ -515,6 +509,35 @@ func escapeBacktickIdent(ident string) string {
|
||||
return strings.ReplaceAll(strings.TrimSpace(ident), "`", "``")
|
||||
}
|
||||
|
||||
func tdengineShowTablesQueries(dbName string) []string {
|
||||
queries := make([]string, 0, 6)
|
||||
appendQuery := func(query string) {
|
||||
query = strings.TrimSpace(query)
|
||||
if query == "" {
|
||||
return
|
||||
}
|
||||
for _, existing := range queries {
|
||||
if existing == query {
|
||||
return
|
||||
}
|
||||
}
|
||||
queries = append(queries, query)
|
||||
}
|
||||
|
||||
db := strings.TrimSpace(dbName)
|
||||
if db != "" {
|
||||
escaped := escapeBacktickIdent(db)
|
||||
appendQuery(fmt.Sprintf("SHOW TABLES FROM `%s`", escaped))
|
||||
appendQuery(fmt.Sprintf("SHOW STABLES FROM `%s`", escaped))
|
||||
appendQuery(fmt.Sprintf("SHOW TABLES FROM %s", db))
|
||||
appendQuery(fmt.Sprintf("SHOW STABLES FROM %s", db))
|
||||
}
|
||||
|
||||
appendQuery("SHOW TABLES")
|
||||
appendQuery("SHOW STABLES")
|
||||
return queries
|
||||
}
|
||||
|
||||
func tdengineDescribeQueries(dbName, tableName string) []string {
|
||||
qualified := quoteTDengineTable(dbName, tableName)
|
||||
legacyQualified := quoteTDengineTableLegacy(dbName, tableName)
|
||||
|
||||
Reference in New Issue
Block a user