aboutsummaryrefslogtreecommitdiff
path: root/api/randid.py
diff options
context:
space:
mode:
Diffstat (limited to 'api/randid.py')
-rw-r--r--api/randid.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/api/randid.py b/api/randid.py
index 6c1ca9d..e0baf43 100644
--- a/api/randid.py
+++ b/api/randid.py
@@ -6,13 +6,13 @@ tables = {"users": "user_id", "games": "game_id"}
# generate a new uuid and check for collisions (unlikely but still)
def new_uuid(table_name):
- temp_uuid = str(uuid.uuid4())
- column_name = tables[table_name]
- # check if id is already taken
- if cursor.execute(
- f"select {column_name} from {table_name} where {column_name} = ?",
- [temp_uuid]
- ).fetchone():
- return new_uuid(table_name)
- else:
- return temp_uuid
+ temp_uuid = str(uuid.uuid4())
+ column_name = tables[table_name]
+ # check if id is already taken
+ if cursor.execute(
+ f"select {column_name} from {table_name} where {column_name} = ?",
+ [temp_uuid]
+ ).fetchone():
+ return new_uuid(table_name)
+ else:
+ return temp_uuid