Skip to content

Commit

Permalink
Fixed mistake in JalDB.locate_operation().
Browse files Browse the repository at this point in the history
Trades with no number are allowed.
  • Loading branch information
titov-vv committed May 24, 2024
1 parent b83564e commit 98adcc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion jal/db/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ def locate_operation(self, table_name, fields, data) -> int:
return 0
for field in validation_fields:
if field not in data:
data[field] = fields[field]['default'] # set to default value
if 'default' in fields[field]:
data[field] = fields[field]['default'] # set to default value
else:
raise KeyError(f"Mandatory field '{field}' for table '{table_name}' is missing in {data} and have no default value")
if data[field] is None:
query_text += f"{field} IS NULL AND "
else:
Expand Down
2 changes: 1 addition & 1 deletion jal/db/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ class Trade(LedgerTransaction):
_db_fields = {
"timestamp": {"mandatory": True, "validation": True},
"settlement": {"mandatory": False, "validation": False},
"number": {"mandatory": False, "validation": True},
"number": {"mandatory": False, "validation": True, "default": ''},
"account_id": {"mandatory": True, "validation": True},
"asset_id": {"mandatory": True, "validation": True},
"qty": {"mandatory": True, "validation": True},
Expand Down

0 comments on commit 98adcc0

Please sign in to comment.