Use local variables in fieldPosByName and fix errors

pull/1856/head
Tikhon Fedulov 2023-12-24 13:57:58 +03:00 committed by Jack Christensen
parent 0c7acf9481
commit d2c9ebc2ef
1 changed files with 4 additions and 4 deletions

View File

@ -668,11 +668,11 @@ func fieldPosByName(fldDescs []pgconn.FieldDescription, field string) (i int) {
i = -1 i = -1
for i, desc := range fldDescs { for i, desc := range fldDescs {
// Support snake and spinal case. // Snake case support.
desc.Name = strings.ReplaceAll(desc.Name, "_", "") field = strings.ReplaceAll(field, "_", "")
desc.Name = strings.ReplaceAll(desc.Name, "-", "") descName := strings.ReplaceAll(desc.Name, "_", "")
if strings.EqualFold(desc.Name, field) { if strings.EqualFold(descName, field) {
return i return i
} }
} }