diff --git a/src/db/db.go b/src/db/db.go index 19791ce..fb25b19 100644 --- a/src/db/db.go +++ b/src/db/db.go @@ -158,7 +158,11 @@ func QueryOne[T any]( result, hasRow := rows.Next() if !hasRow { - return nil, NotFound + if readErr := rows.Err(); readErr != nil { + return nil, readErr + } else { + return nil, NotFound + } } return result, nil @@ -244,7 +248,11 @@ func QueryOneScalar[T any]( result, hasRow := rows.Next() if !hasRow { var zero T - return zero, NotFound + if readErr := rows.Err(); readErr != nil { + return zero, readErr + } else { + return zero, NotFound + } } return *result, nil @@ -585,6 +593,10 @@ func (it *Iterator[T]) Next() (*T, bool) { } } +func (it *Iterator[T]) Err() error { + return it.rows.Err() +} + // Takes a value from a database query (reflected) and assigns it to the // destination. If the destination is a pointer, and the value is non-nil, it // will initialize the destination before assigning.