diff options
author | 2024-09-16 09:26:41 +0200 | |
---|---|---|
committer | 2024-09-16 09:26:41 +0200 | |
commit | ca729aa4a06b5d7e5587e2b2e2a0b87bfb17513c (patch) | |
tree | 15147a61f3a12edba73c2add3aabf620b49c5d36 /vendor/github.com/jackc/pgx/v5/rows.go | |
parent | [bugfix] Hoist filterable text field extraction out of loop (#3297) (diff) | |
download | gotosocial-ca729aa4a06b5d7e5587e2b2e2a0b87bfb17513c.tar.xz |
[chore]: Bump github.com/jackc/pgx/v5 from 5.6.0 to 5.7.1 (#3302)
Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.6.0 to 5.7.1.
- [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jackc/pgx/compare/v5.6.0...v5.7.1)
---
updated-dependencies:
- dependency-name: github.com/jackc/pgx/v5
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
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.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/rows.go b/vendor/github.com/jackc/pgx/v5/rows.go index d4f7a9016..f23625d4c 100644 --- a/vendor/github.com/jackc/pgx/v5/rows.go +++ b/vendor/github.com/jackc/pgx/v5/rows.go @@ -797,7 +797,7 @@ func computeNamedStructFields( if !dbTagPresent { colName = sf.Name } - fpos := fieldPosByName(fldDescs, colName) + fpos := fieldPosByName(fldDescs, colName, !dbTagPresent) if fpos == -1 { if missingField == "" { missingField = colName @@ -816,16 +816,21 @@ func computeNamedStructFields( const structTagKey = "db" -func fieldPosByName(fldDescs []pgconn.FieldDescription, field string) (i int) { +func fieldPosByName(fldDescs []pgconn.FieldDescription, field string, normalize bool) (i int) { i = -1 - for i, desc := range fldDescs { - // Snake case support. + if normalize { field = strings.ReplaceAll(field, "_", "") - descName := strings.ReplaceAll(desc.Name, "_", "") - - if strings.EqualFold(descName, field) { - return i + } + for i, desc := range fldDescs { + if normalize { + if strings.EqualFold(strings.ReplaceAll(desc.Name, "_", ""), field) { + return i + } + } else { + if desc.Name == field { + return i + } } } return |