From f79d61a9eef42a05aca6f4ddb8d95192549036a5 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 8 May 2026 16:52:45 +0200 Subject: allow both None or ErrNoRows in SelectOne{,Where} The None-returning style is more convenient when the application needs to genuinely behave differently in this case, e.g. returning 404 from an HTTP API endpoint (instead of 500 for a generic database error). The ErrNoRows-returning style is more convenient when control flow is not different for this case vs. other error cases. --- benchmark/benchmark_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'benchmark/benchmark_test.go') diff --git a/benchmark/benchmark_test.go b/benchmark/benchmark_test.go index b389d38..721d3a2 100644 --- a/benchmark/benchmark_test.go +++ b/benchmark/benchmark_test.go @@ -189,12 +189,12 @@ func BenchmarkSelectOne(b *testing.B) { precomputedQuery := store.MustPrepareSelectQueryWhere(partialQuery) selectWithOblast := func(b *testing.B) { - r := must.Return(store.SelectOne(noctx, db, query))(b).UnwrapOrPanic("missing record") + r := must.Return(store.SelectOne(noctx, db, query))(b) assert.Equal(b, r.ID, recordID) } selectWithOblastWhere := func(b *testing.B) { - r := must.Return(precomputedQuery.SelectOne(noctx, db))(b).UnwrapOrPanic("missing record") + r := must.Return(precomputedQuery.SelectOne(noctx, db))(b) assert.Equal(b, r.ID, recordID) } -- cgit v1.2.3