Skip to content

Commit 95af8eb

Browse files
committed
fix(databases): use catalog name in full_name output instead of hardcoded default
1 parent f2b2798 commit 95af8eb

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/databases.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ pub fn is_parquet_path(path: &str) -> bool {
202202
|| Path::new(path).extension().and_then(|e| e.to_str()) == Some("parquet")
203203
}
204204

205-
fn table_rows(tables: Vec<InfoTable>) -> Vec<TableRow> {
205+
fn table_rows(catalog: &str, tables: Vec<InfoTable>) -> Vec<TableRow> {
206206
tables
207207
.into_iter()
208208
.map(|t| TableRow {
209-
full_name: format!("default.{}.{}", t.schema, t.table),
209+
full_name: format!("{catalog}.{}.{}", t.schema, t.table),
210210
schema: t.schema,
211211
table: t.table,
212212
synced: t.synced,
@@ -566,7 +566,8 @@ pub fn tables_list(workspace_id: &str, database: Option<&str>, schema: Option<&s
566566
let db = resolve_database(&api, &database);
567567
let tables = collect_tables(&api, &db.default_connection_id, schema);
568568

569-
let rows = table_rows(tables);
569+
let catalog = db.name.as_deref().unwrap_or("default");
570+
let rows = table_rows(catalog, tables);
570571

571572
match format {
572573
"json" => println!("{}", serde_json::to_string_pretty(&rows).unwrap()),
@@ -655,7 +656,8 @@ pub fn tables_load(
655656
}
656657
};
657658

658-
let full_name = format!("default.{}.{}", result.schema_name, result.table_name);
659+
let catalog = db.name.as_deref().unwrap_or("default");
660+
let full_name = format!("{catalog}.{}.{}", result.schema_name, result.table_name);
659661
println!("{}", "Table loaded".green());
660662
println!("full_name: {}", full_name.clone().green());
661663
println!("rows: {}", result.row_count);
@@ -872,16 +874,16 @@ mod tests {
872874
}
873875

874876
#[test]
875-
fn table_rows_uses_default_prefix() {
876-
let rows = table_rows(vec![InfoTable {
877+
fn table_rows_uses_catalog_prefix() {
878+
let rows = table_rows("mydb", vec![InfoTable {
877879
connection: "ignored".into(),
878880
schema: "public".into(),
879881
table: "orders".into(),
880882
synced: true,
881883
last_sync: Some("2026-05-19T00:00:00Z".into()),
882884
}]);
883885
assert_eq!(rows.len(), 1);
884-
assert_eq!(rows[0].full_name, "default.public.orders");
886+
assert_eq!(rows[0].full_name, "mydb.public.orders");
885887
assert!(rows[0].synced);
886888
}
887889

0 commit comments

Comments
 (0)