Skip to content

Commit

Permalink
chore: use convert to support more types
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jan 6, 2022
1 parent 780504c commit 6e26223
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dbfixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ func defaultFuncs() template.FuncMap {
}

func scanFieldValue(strct reflect.Value, field *schema.Field, value interface{}) error {
if v := reflect.ValueOf(value); field.StructField.Type == v.Type() {
field.Value(strct).Set(v)
if v := reflect.ValueOf(value); v.CanConvert(field.StructField.Type) {
field.Value(strct).Set(v.Convert(field.StructField.Type))
return nil
}
return field.ScanValue(strct, value)
Expand Down

0 comments on commit 6e26223

Please sign in to comment.