From 8308491d9a7243f10d2ae23b701a401e44dca1e8 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 4 Aug 2014 14:37:51 +0800 Subject: [PATCH] Fix AutoMigrate with nested Scanner --- scope_private.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scope_private.go b/scope_private.go index cfe30458..ca6b7eb5 100644 --- a/scope_private.go +++ b/scope_private.go @@ -339,7 +339,14 @@ func (scope *Scope) sqlTagForField(field *Field) (typ string) { } case reflect.Struct: if field.IsScanner() { - reflectValue = reflectValue.Field(0) + var getScannerValue func(reflect.Value) + getScannerValue = func(value reflect.Value) { + reflectValue = value + if _, isScanner := reflect.New(reflectValue.Type()).Interface().(sql.Scanner); isScanner { + getScannerValue(reflectValue.Field(0)) + } + } + getScannerValue(reflectValue.Field(0)) } else if !field.IsTime() { return }