Skip to content

Commit 1d201bb

Browse files
authored
fix(databases): use name not description for API alignment (#112)
* fix(databases): use name not description for API alignment The Hotdata API renamed the database identifier field from `description` to `name`. This updates: - `try_resolve_database`: filter by `d.name` instead of `d.description` so that `hotdata databases get <name>` works against the new API - `databases set`: accept the database id directly rather than resolving by name/description — the id is unambiguous and always available - Error messages and help text: "id or description" → "id or name" - Tests: update mock payloads to return `name` (not `description`) * fix(databases): implement dot-notation schema parsing in create_database_request The --table flag doc comments claimed that `schema.table` entries would land in the named schema, but the implementation was sending literal strings as table names inside a single schema. This implements the promised behavior: entries with a dot are split into (schema, table) and grouped accordingly, bare names fall back to the --schema default. Adds a test covering the multi-schema case. Also removes an extra blank line between resolve_database and schema_name. * fix(databases): remove stale description field and --description flag - Drop `description` field from DatabaseSummary, Database, and CreateDatabaseResponse structs — the API now returns `name` only - Remove `--description` flag from `databases create` and the corresponding `"description"` JSON key from create_database_request - Drop DESCRIPTION column from `databases list` table output - Remove the always-blank `description: -` row from `databases show` - `databases set` now resolves the input to a real db.id before saving, validating the database exists and ensuring the config always holds an ID - Rename id_or_description params to id_or_name in get/delete/set - Update all tests and the databases_cli integration test * fix(databases): reorder list columns to ID then NAME * fix(databases): set accepts only IDs, rejects names --------- Co-authored-by: Eddie A Tejeda <669988+eddietejeda@users.noreply.github.com>
1 parent bfabb45 commit 1d201bb

4 files changed

Lines changed: 147 additions & 91 deletions

File tree

src/command.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub enum Commands {
7575

7676
/// Managed databases you create and populate with tables (parquet uploads)
7777
Databases {
78-
/// Database id or description (omit to use a subcommand)
78+
/// Database id or name (omit to use a subcommand)
7979
name_or_id: Option<String>,
8080

8181
/// Workspace ID (defaults to first workspace from login)
@@ -563,20 +563,28 @@ pub enum DatabasesCommands {
563563

564564
/// Create a new managed database
565565
Create {
566-
/// Optional display label (not unique, not an identifier — databases are addressed by id)
566+
/// SQL catalog alias — becomes the catalog name in queries:
567+
/// SELECT … FROM <name>.public.<table>.
568+
/// Must be [a-z_][a-z0-9_]*, globally unique. When provided the
569+
/// database defaults to no expiry; omit for an anonymous 24h sandbox.
567570
#[arg(long)]
568-
description: Option<String>,
571+
name: Option<String>,
569572

570-
/// Schema for tables declared at create time (default: public)
573+
/// Default schema for bare `--table` entries (default: public).
574+
/// Use dot notation in `--table` to target a different schema directly,
575+
/// e.g. `--table raw.raw_orders` always goes into the "raw" schema.
571576
#[arg(long, default_value = "public")]
572577
schema: String,
573578

574-
/// Table to declare up front (repeatable)
579+
/// Table to declare up front (repeatable). Accepts bare names or
580+
/// `schema.table` dot notation to span multiple schemas in one command:
581+
/// --table orders --table raw.raw_orders --table raw.raw_customers
575582
#[arg(long = "table")]
576583
tables: Vec<String>,
577584

578585
/// When the database expires. Accepts a relative duration (e.g. 24h, 7d, 90m)
579-
/// or an RFC 3339 timestamp. Defaults to 24h when omitted.
586+
/// or an RFC 3339 timestamp. Omitting with --name means no expiry; omitting
587+
/// without --name defaults to 24h.
580588
#[arg(long)]
581589
expires_at: Option<String>,
582590

@@ -587,8 +595,8 @@ pub enum DatabasesCommands {
587595

588596
/// Set the current database (used by default when no database is specified)
589597
Set {
590-
/// Database id or description
591-
id_or_description: String,
598+
/// Database id
599+
id: String,
592600
},
593601

594602
/// Delete a managed database and its tables
@@ -618,7 +626,7 @@ pub enum DatabasesCommands {
618626

619627
/// Manage tables inside a managed database
620628
Tables {
621-
/// Database id or description — shorthand for `tables list` when no subcommand is given
629+
/// Database id or name — shorthand for `tables list` when no subcommand is given
622630
database: Option<String>,
623631

624632
#[command(subcommand)]
@@ -630,7 +638,7 @@ pub enum DatabasesCommands {
630638
pub enum DatabaseTablesCommands {
631639
/// List tables in a managed database
632640
List {
633-
/// Database id or description (defaults to current database)
641+
/// Database id or name (defaults to current database)
634642
#[arg(long)]
635643
database: Option<String>,
636644

@@ -645,7 +653,7 @@ pub enum DatabaseTablesCommands {
645653

646654
/// Load a parquet file into a table (creates or replaces the table)
647655
Load {
648-
/// Database id or description (defaults to current database)
656+
/// Database id or name (defaults to current database)
649657
#[arg(long)]
650658
database: Option<String>,
651659

@@ -671,7 +679,7 @@ pub enum DatabaseTablesCommands {
671679

672680
/// Delete a table from a managed database
673681
Delete {
674-
/// Database id or description (defaults to current database)
682+
/// Database id or name (defaults to current database)
675683
#[arg(long)]
676684
database: Option<String>,
677685

0 commit comments

Comments
 (0)