Fix tests for association

This commit is contained in:
Jinzhu 2014-09-02 20:10:18 +08:00
parent 953c347ba7
commit 59846f0e9b
1 changed files with 4 additions and 0 deletions

View File

@ -38,6 +38,10 @@ func (field *Field) IsTime() bool {
func (field *Field) Set(value interface{}) (result bool) {
if field.Field.IsValid() && field.Field.CanAddr() {
result = true
if rvalue, ok := value.(reflect.Value); ok {
value = rvalue.Interface()
}
if scanner, ok := field.Field.Addr().Interface().(sql.Scanner); ok {
scanner.Scan(value)
} else if reflect.TypeOf(value).ConvertibleTo(field.Field.Type()) {