v0.0.384 QuerySingleOpt
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m28s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m28s
This commit is contained in:
parent
30ce8c4b60
commit
1869ff3d75
@ -1,5 +1,5 @@
|
||||
package goext
|
||||
|
||||
const GoextVersion = "0.0.383"
|
||||
const GoextVersion = "0.0.384"
|
||||
|
||||
const GoextVersionTimestamp = "2024-02-09T15:17:51+0100"
|
||||
const GoextVersionTimestamp = "2024-02-09T15:20:46+0100"
|
||||
|
@ -103,6 +103,23 @@ func QuerySingle[TData any](ctx context.Context, q Queryable, sql string, pp PP,
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func QuerySingleOpt[TData any](ctx context.Context, q Queryable, sqlstr string, pp PP, mode StructScanMode, sec StructScanSafety) (*TData, error) {
|
||||
rows, err := q.Query(ctx, sqlstr, pp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, err := ScanSingle[TData](ctx, q, rows, mode, sec, true)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &data, nil
|
||||
}
|
||||
|
||||
func QueryAll[TData any](ctx context.Context, q Queryable, sql string, pp PP, mode StructScanMode, sec StructScanSafety) ([]TData, error) {
|
||||
rows, err := q.Query(ctx, sql, pp)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user