mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-24 03:17:00 +00:00
fix(starrocks): detect primary keys via information_schema.COLUMNS
* 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`)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user