Skip to content

Commit be3cb23

Browse files
committed
fix: handle version number internally in CommandLib to be consistent with web client.
1 parent 1cff30a commit be3cb23

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

python/datafed_pkg/datafed/CommandLib.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,11 @@ def schemaCreate(self, schema_id, definition=None, definition_file=None,
382382
self._validate_json(definition, "Schema definition")
383383

384384
msg = sdms.SchemaCreateRequest()
385-
msg.id = schema_id
385+
386+
if ":" in schema_id:
387+
raise Exception("Colons are not allowed when creating a schema id.")
388+
389+
msg.id = schema_id + ":0"
386390
# See note above: "def" is a Python reserved keyword.
387391
setattr(msg, 'def', definition)
388392

@@ -440,7 +444,17 @@ def schemaRevise(self, schema_id, definition=None, definition_file=None,
440444
self._validate_json(definition, "Schema definition")
441445

442446
msg = sdms.SchemaReviseRequest()
443-
msg.id = schema_id
447+
448+
if ":" not in schema_id:
449+
raise Exception("Schema id is missing ':<version>'.")
450+
451+
try:
452+
base, ver_str = schema_id.rsplit(":", 1)
453+
ver = int(ver_str)
454+
except (ValueError, IndexError):
455+
raise Exception(f"Malformed schema_id {schema_id}")
456+
457+
msg.id = base + f":{ver + 1}"
444458

445459
if definition is not None:
446460
# See schema section note: "def" is a Python reserved keyword.

0 commit comments

Comments
 (0)