Skip to content

Commit bfd7f85

Browse files
committed
fix db.QueryStruct
1 parent 16fe7df commit bfd7f85

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

db/query.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ func QueryValueOrDefault[T any](ctx context.Context, query string, args ...any)
6363
// with primary key flags to identify the primary key column names
6464
// for the passed pkValue+pkValues and a table name.
6565
func QueryStruct[S any](ctx context.Context, pkValue any, pkValues ...any) (row *S, err error) {
66-
if len(pkValues) > 0 {
67-
pkValues = append([]any{pkValue}, pkValues...)
68-
}
66+
// Using explicit first pkValue value
67+
// to not be able to compile without any value
68+
pkValues = append([]any{pkValue}, pkValues...)
6969
t := reflect.TypeOf(row).Elem()
7070
if t.Kind() != reflect.Struct {
7171
return nil, fmt.Errorf("expected struct template type instead of %s", t)

0 commit comments

Comments
 (0)