mirror of https://github.com/go-gorm/gorm.git
Support specify GORM tag setting inside scanner
This commit is contained in:
parent
35a2a004d8
commit
f26fa242cc
|
@ -117,7 +117,7 @@ type Company struct {
|
|||
}
|
||||
|
||||
type Role struct {
|
||||
Name string
|
||||
Name string `gorm:"size:256"`
|
||||
}
|
||||
|
||||
func (role *Role) Scan(value interface{}) error {
|
||||
|
|
|
@ -188,6 +188,13 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
|
|||
if _, isScanner := fieldValue.(sql.Scanner); isScanner {
|
||||
// is scanner
|
||||
field.IsScanner, field.IsNormal = true, true
|
||||
if indirectType.Kind() == reflect.Struct {
|
||||
for i := 0; i < indirectType.NumField(); i++ {
|
||||
for key, value := range parseTagSetting(indirectType.Field(i).Tag) {
|
||||
field.TagSettings[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if _, isTime := fieldValue.(*time.Time); isTime {
|
||||
// is time
|
||||
field.IsNormal = true
|
||||
|
|
Loading…
Reference in New Issue