mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-21 16:34:21 +08:00
🐛 fix(vastbase): 修复含点表名误识别为模式 (#757)
- 对含点号或双引号的 PostgreSQL-like 标识符进行可逆引用 - 让 Vastbase 表列表复用统一的 PostgreSQL 元数据解析 - 增加含点表名保持标识符边界的回归测试 Refs #757
This commit is contained in:
@@ -379,9 +379,9 @@ func parsePostgresTableNames(data []map[string]interface{}) []string {
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
table := name
|
||||
table := encodePGLikeQualifiedNamePart(name)
|
||||
if schema != "" {
|
||||
table = fmt.Sprintf("%s.%s", schema, name)
|
||||
table = fmt.Sprintf("%s.%s", encodePGLikeQualifiedNamePart(schema), table)
|
||||
}
|
||||
key := strings.ToLower(table)
|
||||
if _, exists := seen[key]; exists {
|
||||
@@ -393,6 +393,13 @@ func parsePostgresTableNames(data []map[string]interface{}) []string {
|
||||
return tables
|
||||
}
|
||||
|
||||
func encodePGLikeQualifiedNamePart(identifier string) string {
|
||||
if !strings.ContainsAny(identifier, `."`) {
|
||||
return identifier
|
||||
}
|
||||
return `"` + strings.ReplaceAll(identifier, `"`, `""`) + `"`
|
||||
}
|
||||
|
||||
func (p *PostgresDB) GetCreateStatement(dbName, tableName string) (string, error) {
|
||||
return fmt.Sprintf("-- SHOW CREATE TABLE not fully supported for PostgreSQL in this MVP.\n-- Table: %s", tableName), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user