This commit is contained in:
Magnus Åhall 2026-08-23 10:20:02 +02:00
parent e68a66f5ce
commit 24befcce36
3 changed files with 22 additions and 10 deletions

View file

@ -285,19 +285,13 @@ func DatapointRetrieve(id int, name string) (dp Datapoint, err error) { // {{{
rows, _ := db.Query(context.Background(), query, param)
dp, err = pgx.CollectExactlyOneRow(rows, pgx.RowToStructByNameLax[Datapoint])
if err != nil {
err = werr.Wrap(err)
return
}
if err == sql.ErrNoRows {
if errors.Is(err, pgx.ErrNoRows) {
dp = Datapoint{
Name: name,
}
err = nil
return
}
if err != nil {
err = werr.Wrap(err).WithData(name)
return
@ -315,7 +309,7 @@ func DatapointRetrieve(id int, name string) (dp Datapoint, err error) { // {{{
dp.ID,
)
dp.LastDatapointValue, err = pgx.CollectExactlyOneRow(rows, pgx.RowToStructByNameLax[DatapointValue])
if err == sql.ErrNoRows {
if errors.Is(err, pgx.ErrNoRows) {
err = nil
return
}