mirror of
https://github.com/jackc/pgx.git
synced 2025-05-31 11:42:24 +00:00
Add snake_case support to RowToStructByName
This commit is contained in:
parent
cbc5a7055f
commit
0c7acf9481
5
rows.go
5
rows.go
@ -667,6 +667,11 @@ const structTagKey = "db"
|
||||
func fieldPosByName(fldDescs []pgconn.FieldDescription, field string) (i int) {
|
||||
i = -1
|
||||
for i, desc := range fldDescs {
|
||||
|
||||
// Support snake and spinal case.
|
||||
desc.Name = strings.ReplaceAll(desc.Name, "_", "")
|
||||
desc.Name = strings.ReplaceAll(desc.Name, "-", "")
|
||||
|
||||
if strings.EqualFold(desc.Name, field) {
|
||||
return i
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user