Move pr 3784 here

This commit is contained in:
Ming Deng 2020-09-07 20:36:54 +08:00
parent 8e015deee5
commit 6bf01eaeca
1 changed files with 8 additions and 1 deletions

View File

@ -330,6 +330,8 @@ func (o *rawSet) QueryRow(containers ...interface{}) error {
return err
}
structTagMap := make(map[reflect.StructTag]map[string]string)
defer rows.Close()
if rows.Next() {
@ -396,7 +398,12 @@ func (o *rawSet) QueryRow(containers ...interface{}) error {
recursiveSetField(f)
}
_, tags := parseStructTag(fe.Tag.Get(defaultStructTagName))
// thanks @Gazeboxu.
tags := structTagMap[fe.Tag]
if tags == nil {
_, tags = parseStructTag(fe.Tag.Get(defaultStructTagName))
structTagMap[fe.Tag] = tags
}
var col string
if col = tags["column"]; col == "" {
col = nameStrategyMap[nameStrategy](fe.Name)