Fix tests failing (#36)

Reviewed-on: #36
This commit was merged in pull request #36.
This commit is contained in:
2025-05-13 19:34:43 +02:00
parent f29eeae9d9
commit 94a20af04d
2 changed files with 16 additions and 8 deletions

View File

@@ -49,11 +49,8 @@ func (db *Db) GetUsers() ([]User, error) {
func (db *Db) GetUser(id int) (*UserWithAllowance, error) {
user := &UserWithAllowance{}
err := db.db.Query("select u.id, u.name, sum(h.amount) from users u join history h on h.user_id = u.id where u.id = ?").
err := db.db.Query("select u.id, u.name, (select ifnull(sum(h.amount), 0) from history h where h.user_id = u.id) from users u where u.id = ?").
Bind(id).ScanSingle(&user.ID, &user.Name, &user.Allowance)
if errors.Is(err, mysqlite.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, err
}