home
·
contact
·
privacy
projects
/
plomtask
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4ee3cc7
)
Ensure stringy BaseModel IDs are not empty.
author
Christian Heller
<c.heller@plomlompom.de>
Fri, 14 Jun 2024 18:12:16 +0000
(20:12 +0200)
committer
Christian Heller
<c.heller@plomlompom.de>
Fri, 14 Jun 2024 18:12:16 +0000
(20:12 +0200)
plomtask/db.py
patch
|
blob
|
history
diff --git
a/plomtask/db.py
b/plomtask/db.py
index 2077d79f22450be197aa72fbbfccbc5a35a9b2e9..b2f2142c9c6957c19e90674270a1635082050f59 100644
(file)
--- a/
plomtask/db.py
+++ b/
plomtask/db.py
@@
-245,6
+245,9
@@
class BaseModel(Generic[BaseModelId]):
if isinstance(id_, int) and id_ < 1:
msg = f'illegal {self.__class__.__name__} ID, must be >=1: {id_}'
raise HandledException(msg)
+ if isinstance(id_, str) and "" == id_:
+ msg = f'illegal {self.__class__.__name__} ID, must be non-empty'
+ raise HandledException(msg)
self.id_ = id_
def __eq__(self, other: object) -> bool: