Skip to content

Commit b614f7e

Browse files
committed
don't use ~struct{} type constraint
1 parent 38cd3a9 commit b614f7e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

db/query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func QueryValueOrDefault[T any](ctx context.Context, query string, args ...any)
6060
}
6161

6262
// QueryRowStruct queries a row and scans it as struct.
63-
func QueryRowStruct[S ~struct{}](ctx context.Context, query string, args ...any) (row *S, err error) {
63+
func QueryRowStruct[S any](ctx context.Context, query string, args ...any) (row *S, err error) {
6464
err = Conn(ctx).QueryRow(query, args...).ScanStruct(&row)
6565
if err != nil {
6666
return nil, err
@@ -70,7 +70,7 @@ func QueryRowStruct[S ~struct{}](ctx context.Context, query string, args ...any)
7070

7171
// QueryRowStructOrNil queries a row and scans it as struct
7272
// or returns nil in case of sql.ErrNoRows.
73-
func QueryRowStructOrNil[S ~struct{}](ctx context.Context, query string, args ...any) (row *S, err error) {
73+
func QueryRowStructOrNil[S any](ctx context.Context, query string, args ...any) (row *S, err error) {
7474
err = Conn(ctx).QueryRow(query, args...).ScanStruct(&row)
7575
if err != nil {
7676
if errors.Is(err, sql.ErrNoRows) {
@@ -85,7 +85,7 @@ func QueryRowStructOrNil[S ~struct{}](ctx context.Context, query string, args ..
8585
// and scan it into a struct of type S that must have tagged fields
8686
// with primary key flags to identify the primary key column names
8787
// for the passed pkValue+pkValues and a table name.
88-
func GetRow[S ~struct{}](ctx context.Context, pkValue any, pkValues ...any) (row *S, err error) {
88+
func GetRow[S any](ctx context.Context, pkValue any, pkValues ...any) (row *S, err error) {
8989
// Using explicit first pkValue value
9090
// to not be able to compile without any value
9191
pkValues = append([]any{pkValue}, pkValues...)
@@ -119,7 +119,7 @@ func GetRow[S ~struct{}](ctx context.Context, pkValue any, pkValues ...any) (row
119119
// for the passed pkValue+pkValues and a table name.
120120
// Returns nil as row and error if no row could be found with the
121121
// passed pkValue+pkValues.
122-
func GetRowOrNil[S ~struct{}](ctx context.Context, pkValue any, pkValues ...any) (row *S, err error) {
122+
func GetRowOrNil[S any](ctx context.Context, pkValue any, pkValues ...any) (row *S, err error) {
123123
row, err = GetRow[S](ctx, pkValue, pkValues...)
124124
if err != nil {
125125
if errors.Is(err, sql.ErrNoRows) {

0 commit comments

Comments
 (0)