fix(indexes): accept --catalog on 'indexes delete'#197
Merged
Conversation
`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
| #[arg(long, requires = "connection_id")] | ||
| /// Schema name | ||
| #[arg(long)] | ||
| schema: Option<String>, |
Contributor
There was a problem hiding this comment.
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, |
Codecov Report❌ Patch coverage is
📢 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).
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hotdata indexes createscopes the table with--catalog <alias>(resolved to the backing connection — including a managed database'sdefault_connection_id), buthotdata indexes deleteaccepted only a raw--connection-id. On a managed database, the only value that works is thedefault_connection_idfrom the originaldatabases createresponse, which isn't surfaced byindexes listor anydatabasessubcommand — 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 deletethe same--catalogflag andresolve_connection_idresolution thatindexes createalready uses:indexes delete --catalog <alias> --schema <s> --table <t> --name <idx>— resolves the catalog (or connection name) to the connection, mirroringcreate.--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-idasymmetry betweencreateanddelete.Verification
Built
target/debug/hotdataand ran against a live workspace:cargo fmt --checkclean; all existing tests pass; the edits add no new clippy warnings.