From f2f4ef81cac8a0daf9076575c88d081c3349003e Mon Sep 17 00:00:00 2001 From: deoxxa Date: Thu, 22 Jan 2015 18:15:09 +1100 Subject: [PATCH] support embedded structs if they support the sql.Scanner interface --- callback_create.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/callback_create.go b/callback_create.go index 52e9369c..34612f6b 100644 --- a/callback_create.go +++ b/callback_create.go @@ -2,6 +2,7 @@ package gorm import ( "fmt" + "reflect" "strings" ) @@ -30,7 +31,11 @@ func Create(scope *Scope) { continue } columns = append(columns, scope.Quote(field.DBName)) - sqls = append(sqls, scope.AddToVars(field.Field.Interface())) + val := field.Field + if val.Kind() == reflect.Struct { + val = val.Addr() + } + sqls = append(sqls, scope.AddToVars(val.Interface())) } }