Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(postgres): handle localized missing prokind errors

t8y291b4623278e6
diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs
index 5797b993f5..bc28ee1a77 100644
--- a/crates/dbx-core/src/schema.rs
+++ b/crates/dbx-core/src/schema.rs
@@ -9420,10 +9420,19 @@ async fn postgres_object_source(
fn postgres_missing_prokind_error(err: &str) -> bool {
let lower = err.to_ascii_lowercase();
- lower.contains("does not exist")
- && (lower.contains("column p.prokind")
- || lower.contains("column \"p\".\"prokind\"")
- || lower.contains("column \"prokind\""))
+ let mentions_prokind =
+ lower.contains("p.prokind") || lower.contains("\"p\".\"prokind\"") || lower.contains("\"prokind\"");
+ if !mentions_prokind {
+ return false;
+ }
+
+ // PostgreSQL localizes the undefined-column message (for example, Chinese
+ // servers report "字段 p.prokind 不存在"). Keep the column context so an
+ // unrelated relation named `prokind` cannot trigger this compatibility path.
+ let undefined_column = lower.contains("sqlstate 42703")
+ || (lower.contains("does not exist") && lower.contains("column"))
+ || (err.contains("不存在") && (err.contains("字段") || err.contains("列 p.prokind")));
+ undefined_column
}
fn opengauss_sequence_cache_metadata_error(err: &str) -> bool {
@@ -9705,7 +9714,11 @@ mod object_source_tests {
fn detects_legacy_postgres_prokind_errors() {
assert!(postgres_missing_prokind_error("ERROR: column p.prokind does not exist"));
assert!(postgres_missing_prokind_error("ERROR: column \"p\".\"prokind\" does not exist"));
+ assert!(postgres_missing_prokind_error("错误: 字段 p.prokind 不存在\n提示: 也许您想要引用列 \"p.probin\"。"));
+ assert!(postgres_missing_prokind_error("ERROR: undefined column p.prokind (SQLSTATE 42703)"));
assert!(!postgres_missing_prokind_error("ERROR: relation public.prokind does not exist"));
+ assert!(!postgres_missing_prokind_error("错误: 关系 public.prokind 不存在\n提示: 请检查列 p.probin。"));
+ assert!(!postgres_missing_prokind_error("ERROR: permission denied for column p.prokind"));
}
#[test]