From e365e8c2fd4e3a595c696849734236008fc67e1f Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 2 May 2023 14:15:25 -0500 Subject: implement basic user operations --- db/user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db/user.go') diff --git a/db/user.go b/db/user.go index 61e05ad..27e6f89 100644 --- a/db/user.go +++ b/db/user.go @@ -9,7 +9,7 @@ import ( func getNextUserId(db *sql.DB) (int, error) { - row := db.QueryRow("select max(userid) from users;") + row := db.QueryRow("select coalesce(max(userid), 0) from users;") if row.Err() != nil { return -1, row.Err() } @@ -19,7 +19,7 @@ func getNextUserId(db *sql.DB) (int, error) { if err != nil { return -1, err } - return id, nil + return id+1, nil } -- cgit v1.2.1