Skip to content

Commit f59ae45

Browse files
committed
db.QueryStructSlice allow pointer to struct
1 parent 055a7bd commit f59ae45

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

db/query.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ func pkColumnsOfStruct(conn sqldb.Connection, t reflect.Type) (table string, col
119119
return table, columns, nil
120120
}
121121

122-
// QueryStructSlice returns queried rows as slice of pointers to the generic struct type S
123-
func QueryStructSlice[S any](ctx context.Context, query string, args ...any) (rows []*S, err error) {
122+
// QueryStructSlice returns queried rows as slice of the generic type S
123+
// which must be a struct or a pointer to a struct.
124+
func QueryStructSlice[S any](ctx context.Context, query string, args ...any) (rows []S, err error) {
124125
err = Conn(ctx).QueryRows(query, args...).ScanStructSlice(&rows)
125126
if err != nil {
126127
return nil, err

0 commit comments

Comments
 (0)