summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v5/rows.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-08-16 16:10:13 +0100
committerLibravatar GitHub <noreply@github.com>2023-08-16 16:10:13 +0100
commite70629e85637159a577bb8ca5bb48262f8435e11 (patch)
treee2b0e3c456b1a2b91cd783383102bc609412f56a /vendor/github.com/jackc/pgx/v5/rows.go
parent[chore]: Bump github.com/abema/go-mp4 from 0.12.0 to 0.13.0 (#2113) (diff)
downloadgotosocial-e70629e85637159a577bb8ca5bb48262f8435e11.tar.xz
[chore]: Bump github.com/jackc/pgx/v5 from 5.4.2 to 5.4.3 (#2112)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/rows.go')
-rw-r--r--vendor/github.com/jackc/pgx/v5/rows.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/rows.go b/vendor/github.com/jackc/pgx/v5/rows.go
index 055a6645a..1b1c8ac9a 100644
--- a/vendor/github.com/jackc/pgx/v5/rows.go
+++ b/vendor/github.com/jackc/pgx/v5/rows.go
@@ -306,7 +306,7 @@ func (rows *baseRows) Values() ([]any, error) {
copy(newBuf, buf)
values = append(values, newBuf)
default:
- rows.fatal(errors.New("Unknown format code"))
+ rows.fatal(errors.New("unknown format code"))
}
}
@@ -496,7 +496,8 @@ func (rs *mapRowScanner) ScanRow(rows Rows) error {
}
// RowToStructByPos returns a T scanned from row. T must be a struct. T must have the same number a public fields as row
-// has fields. The row and T fields will by matched by position.
+// has fields. The row and T fields will by matched by position. If the "db" struct tag is "-" then the field will be
+// ignored.
func RowToStructByPos[T any](row CollectableRow) (T, error) {
var value T
err := row.Scan(&positionalStructRowScanner{ptrToStruct: &value})
@@ -504,7 +505,8 @@ func RowToStructByPos[T any](row CollectableRow) (T, error) {
}
// RowToAddrOfStructByPos returns the address of a T scanned from row. T must be a struct. T must have the same number a
-// public fields as row has fields. The row and T fields will by matched by position.
+// public fields as row has fields. The row and T fields will by matched by position. If the "db" struct tag is "-" then
+// the field will be ignored.
func RowToAddrOfStructByPos[T any](row CollectableRow) (*T, error) {
var value T
err := row.Scan(&positionalStructRowScanner{ptrToStruct: &value})
@@ -545,6 +547,11 @@ func (rs *positionalStructRowScanner) appendScanTargets(dstElemValue reflect.Val
if sf.Anonymous && sf.Type.Kind() == reflect.Struct {
scanTargets = rs.appendScanTargets(dstElemValue.Field(i), scanTargets)
} else if sf.PkgPath == "" {
+ dbTag, _ := sf.Tag.Lookup(structTagKey)
+ if dbTag == "-" {
+ // Field is ignored, skip it.
+ continue
+ }
scanTargets = append(scanTargets, dstElemValue.Field(i).Addr().Interface())
}
}