Explorar el Código

fix(cli): index-create refuses a flag as a collection or field name

index-create "users email" --unique (collection and field quoted as one
argument) declared a unique index on a field named --unique of a collection
named 'users email'; two such declarations were found on zeus.
fszontagh hace 1 mes
padre
commit
6051fc1b02
Se han modificado 2 ficheros con 15 adiciones y 3 borrados
  1. 10 0
      cli/main.cpp
  2. 5 3
      docs/ROADMAP.md

+ 10 - 0
cli/main.cpp

@@ -714,6 +714,16 @@ bool execCommand(smartbotic::database::Client& client,
                 printError("usage: index-create <collection> <field> [--unique]");
                 return false;
             }
+            // A flag is never a field name. `index-create "users email" --unique`
+            // (collection and field quoted as one argument) used to declare a
+            // unique index on a field named `--unique` of a collection named
+            // `users email` - found on zeus, rebuilt with a WARN at every boot.
+            if (params[0].rfind("--", 0) == 0 || params[1].rfind("--", 0) == 0) {
+                printError("usage: index-create <collection> <field> [--unique] - '" +
+                           (params[1].rfind("--", 0) == 0 ? params[1] : params[0]) +
+                           "' is a flag, not a name (were the collection and field quoted together?)");
+                return false;
+            }
             const bool unique = std::find(params.begin(), params.end(), "--unique") != params.end();
             if (unique) {
                 // v2.11.0 T11 — a duplicate-refusal is not a generic failure:

+ 5 - 3
docs/ROADMAP.md

@@ -463,9 +463,11 @@ joins; see 5c), which does not fit in 10 s. The container is now run with
   (`users.email`, `sessions.refreshToken`) exist and hold postings. The bogus
   ones hold nothing, but because their collections were never written, their
   sub-db never persists and every boot logs `rebuilt ... over 0 row(s)`. Two
-  small gaps behind it: the CLI accepts an argument starting with `--` as a
-  field name, and a collection name may contain a space. Cleanup is
-  `index-drop` of both, the owner's call on a live database.
+  small gaps behind it: the CLI accepted an argument starting with `--` as a
+  field name (fixed on main after 2.14.0: `index-create` refuses it, unreleased),
+  and a collection name may contain a space (open). Cleanup (`index-drop` of
+  both) was handed to the smartbotic session on 2026-10-09 at the owner's
+  request.
 
 ---