Skip to content

fix(indexes): accept --catalog on 'indexes delete'#197

Merged
shefeek-jinnah merged 3 commits into
mainfrom
fix/indexes-delete-catalog-853
Jul 1, 2026
Merged

fix(indexes): accept --catalog on 'indexes delete'#197
shefeek-jinnah merged 3 commits into
mainfrom
fix/indexes-delete-catalog-853

Conversation

@shefeek-jinnah

Copy link
Copy Markdown
Contributor

Summary

hotdata indexes create scopes the table with --catalog <alias> (resolved to the backing connection — including a managed database's default_connection_id), but hotdata indexes delete accepted only a raw --connection-id. On a managed database, the only value that works is the default_connection_id from the original databases create response, which isn't surfaced by indexes list or any databases subcommand — so every natural input (catalog alias, database id, internal __db_* connection name) fails, making it effectively impossible to delete an index without having saved that response.

Fixes hotdata-dev/runtimedb#853 (cross-repo, won't auto-close).

Change

Give indexes delete the same --catalog flag and resolve_connection_id resolution that indexes create already uses:

  • indexes delete --catalog <alias> --schema <s> --table <t> --name <idx> — resolves the catalog (or connection name) to the connection, mirroring create.
  • --connection-id <id> is retained (mutually exclusive with --catalog) for the raw-id case.

No server change — the delete endpoint is unchanged; this is purely client-side connection resolution, closing the --catalog/--connection-id asymmetry between create and delete.

Verification

Built target/debug/hotdata and ran against a live workspace:

indexes create --catalog <cat> --schema public --table hits --name idx_id --column id --type sorted
  → Index created.

# before (this CLI, stock):
indexes delete --connection-id <cat> --schema public --table hits --name idx_id
  → Index 'idx_id' not found        # --connection-id can't take a catalog; no --catalog flag existed

# after (this PR):
indexes delete --catalog <cat> --schema public --table hits --name idx_id
  → Index 'idx_id' deleted.         # resolved catalog → connection, index gone from `indexes list`

cargo fmt --check clean; all existing tests pass; the edits add no new clippy warnings.

`indexes create` takes `--catalog <alias>` (resolved to the backing
connection, including a managed database's default connection), but
`indexes delete` accepted only a raw `--connection-id`. Deleting an index
on a managed database therefore required the `default_connection_id` from
the original `databases create` response — a value not surfaced by
`indexes list` or any `databases` subcommand, so the natural inputs
(catalog alias, database id, internal connection name) all failed.

Give `delete` the same `--catalog` flag and `resolve_connection_id`
resolution that `create` uses; `--connection-id` is retained (mutually
exclusive) for the raw-id case.

Fixes hotdata-dev/runtimedb#853
Comment thread src/command.rs Outdated
#[arg(long, requires = "connection_id")]
/// Schema name
#[arg(long)]
schema: Option<String>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: indexes create defaults --schema to public (line 312), but delete leaves it as a no-default Option and errors when it's absent. So create --catalog x --table t --name idx works, yet the mirror delete --catalog x --table t --name idx fails asking for --schema. Since this PR's goal is to close the create/delete asymmetry, consider giving delete's schema the same default_value = "public". (not blocking)

Suggested change
schema: Option<String>,
/// Schema name (default: public)
#[arg(long, default_value = "public")]
schema: String,

claude[bot]
claude Bot previously approved these changes Jun 30, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes the --catalog/--connection-id asymmetry cleanly; resolution mirrors indexes create. One non-blocking super nit on the --schema default left inline.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.48718% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/main.rs 0.00% 15 Missing ⚠️
src/commands/indexes.rs 98.41% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Review follow-ups for the `indexes delete --catalog` change:

- Enforce "exactly one of --catalog / --connection-id" plus a required
  --table via clap (required_unless_present + conflicts_with), so an
  incomplete invocation fails locally at the usage exit code (2) BEFORE any
  auth pre-flight or network resolution, with the requirements shown in
  --help. The previous runtime check ran after Api::new + connection
  resolution, so a missing-flag mistake surfaced a misleading auth/connection
  error and made a needless round-trip.

- Default --schema to "public", matching `indexes create` (the doc-comment
  advertised create-parity but the schema handling diverged).

- Build the SDK client only on the --catalog branch; the raw --connection-id
  path needs no resolution.

- Add clap-parse tests covering the delete arg combinations (catalog +
  default schema, raw connection-id, missing scope, both scopes, missing
  table).
claude[bot]
claude Bot previously approved these changes Jun 30, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mirrors indexes create's --catalog resolution cleanly; clap enforces the scope/exclusivity constraints and the new arg-parsing tests are meaningful. The prior super nit (defaulting delete's --schema to public) is implemented. LGTM.

Resolve the modify/delete conflict from the src/command.rs -> src/commands/
module refactor (main): src/command.rs was deleted and the IndexesCommands
enum moved to src/commands/indexes.rs. Re-apply the 'indexes delete'
--catalog scope change and its arg tests onto src/commands/indexes.rs; the
main.rs dispatch auto-merged.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. indexes delete now mirrors create's --catalog resolution and defaults --schema to public, closing the asymmetry. Arg-parsing paths are well covered by the new tests.

@shefeek-jinnah shefeek-jinnah merged commit dcdd7b9 into main Jul 1, 2026
14 checks passed
@shefeek-jinnah shefeek-jinnah deleted the fix/indexes-delete-catalog-853 branch July 1, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant