From 6bf01eaeca8b0e8ef4cb9c35e5159a8ae55e9401 Mon Sep 17 00:00:00 2001 From: Ming Deng Date: Mon, 7 Sep 2020 20:36:54 +0800 Subject: [PATCH] Move pr 3784 here --- pkg/client/orm/orm_raw.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/client/orm/orm_raw.go b/pkg/client/orm/orm_raw.go index c2539147..e11e97fa 100644 --- a/pkg/client/orm/orm_raw.go +++ b/pkg/client/orm/orm_raw.go @@ -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)