map the column of the alias name to the struct

Fixed issues#2315
This commit is contained in:
fcodetop 2019-11-27 16:23:37 +08:00 committed by GitHub
parent 59408390c2
commit 4843af1f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -493,7 +493,7 @@ func (scope *Scope) scan(rows *sql.Rows, columns []string, fields []*Field) {
} }
for fieldIndex, field := range selectFields { for fieldIndex, field := range selectFields {
if field.DBName == column { if field.DBName == column || field.Name == column{
if field.Field.Kind() == reflect.Ptr { if field.Field.Kind() == reflect.Ptr {
values[index] = field.Field.Addr().Interface() values[index] = field.Field.Addr().Interface()
} else { } else {