From 21a07651db8016462b6e425bd2affaeb4548f09b Mon Sep 17 00:00:00 2001 From: jischeng <49861575+jischeng@users.noreply.github.com> Date: Fri, 26 Jun 2026 13:25:40 +0800 Subject: [PATCH] fix(starrocks): detect primary keys via information_schema.COLUMNS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(starrocks): detect primary keys via information_schema.COLUMNS The Doris family (StarRocks/Doris) loaded columns through `SHOW COLUMNS` for performance (perf(doris) commit 69ecde8f). However StarRocks reports the `Key` column as `YES`/`NO` instead of MySQL's `PRI`, so `is_primary_key` was never set and the data grid always showed "无主键定位" (keyless edit warning) for tables that actually have a primary key. Switch to `get_columns`, which queries information_schema.COLUMNS first — where `COLUMN_KEY = 'PRI'` correctly identifies primary keys (and only real primary keys, not duplicate-key sort columns) — and still falls back to `SHOW COLUMNS` when information_schema is unavailable. Verified against a live StarRocks connection: information_schema.COLUMNS reports `COLUMN_KEY = 'PRI'` for primary-key columns while `SHOW COLUMNS` reports `Key = YES`. Paimon catalog tables are unaffected (both paths report no primary key for them). * fix(test): add redis_scan_page_size to ConnectionConfig test helpers `d815a16b` (feat(redis): move scan page size to connections) added `redis_scan_page_size` to `ConnectionConfig` but did not update several struct-literal test helpers, so `cargo clippy --workspace --all-targets` fails with `missing field redis_scan_page_size`. This is a pre-existing breakage on `main` (CI has been red since that commit) and is unrelated to this PR's actual change; included here only to unblock CI. Helpers fixed here: - src-tauri/src/commands/connection.rs (`mongodb_config`) - crates/dbx-web/src/routes/connection.rs (`sqlite_config`) --- crates/dbx-core/src/schema.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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)