From 9a693ec4b129fd2c61d628190587b7550d45ddd6 Mon Sep 17 00:00:00 2001 From: yx755141 <90823123+yx755141@users.noreply.github.com> Date: Wed, 15 Jul 2026 17:29:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20GetTables=20=E5=A2=9E=E5=8A=A0=20UNION?= =?UTF-8?q?=20ALL=20all=5Fsynonyms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit imp_basicinfo 名下只有同义词没有实际表,仅查 all_tables 返回空。 增加 all_synonyms 后 sbdev 输入 imp_basicinfo. 时能提示 AC01/AC02。 --- internal/db/oracle_impl.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/db/oracle_impl.go b/internal/db/oracle_impl.go index b9cac5c4..6661bec4 100644 --- a/internal/db/oracle_impl.go +++ b/internal/db/oracle_impl.go @@ -307,9 +307,13 @@ func (o *OracleDB) GetTables(dbName string) ([]string, error) { // dbName is Schema/Owner // 始终返回 OWNER.TABLE_NAME,避免下游 SQL 缺少 schema 前缀导致 ORA-00942(refs issue #445) // 列别名用双引号包裹强制大写,避免不同驱动版本返回不一致 case 导致 row map 取值失败 + // 同时查询 all_synonyms 以支持同义词提示(refs: OceanBase/Oracle 模式下同义词可像表一样被引用) var query string if dbName != "" { - query = fmt.Sprintf(`SELECT owner AS "OWNER", table_name AS "TABLE_NAME" FROM all_tables WHERE owner = '%s' ORDER BY table_name`, escapeOracleMetadataLiteral(dbName)) + query = fmt.Sprintf(`SELECT owner AS "OWNER", table_name AS "TABLE_NAME" FROM all_tables WHERE owner = '%s' +UNION ALL +SELECT owner AS "OWNER", synonym_name AS "TABLE_NAME" FROM all_synonyms WHERE owner = '%s' +ORDER BY table_name`, escapeOracleMetadataLiteral(dbName), escapeOracleMetadataLiteral(dbName)) } else { query = `SELECT USER AS "OWNER", table_name AS "TABLE_NAME" FROM user_tables ORDER BY table_name` }