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(starrocks): detect primary keys via information_schema.COLUMNS

jischeng21a07651db80
diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs
index f46e234153..756e012f76 100644
--- a/crates/dbx-core/src/schema.rs
+++ b/crates/dbx-core/src/schema.rs
@@ -2471,7 +2471,15 @@ pub async fn get_columns_core(
}
PoolKind::Mysql(p, _) if db_config.as_ref().is_some_and(is_doris_family_config) => {
let metadata_database = mysql_show_metadata_database_for_config(db_config.as_ref(), database);
- db::mysql::get_columns_show(p, metadata_database, table).await.map(deduplicate_column_infos)
+ // Doris/StarRocks previously went straight to `SHOW COLUMNS` for
+ // speed (see perf(doris) commit), but `SHOW COLUMNS` reports the
+ // `Key` column as `YES`/`NO` rather than MySQL's `PRI`, so primary
+ // keys were never detected. `get_columns` queries
+ // information_schema.COLUMNS first — where `COLUMN_KEY = 'PRI'`
+ // correctly identifies primary keys (and only real primary keys,
+ // not duplicate-key sort columns) — and falls back to `SHOW COLUMNS`
+ // automatically when information_schema is unavailable.
+ db::mysql::get_columns(p, metadata_database, table).await.map(deduplicate_column_infos)
}
PoolKind::Mysql(p, mode) => {
dispatch_mysql!(p, mode, db::mysql::get_columns, db::ob_oracle::get_columns, database, table)