From 1726cebc2ea5c9a35fae41783c6cb9f23dd9bbbf Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 16 Feb 2015 12:04:46 +0800 Subject: [PATCH] update --- field.go | 3 ++- struct_field.go => model_struct.go | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) rename struct_field.go => model_struct.go (91%) diff --git a/field.go b/field.go index 4245b6cb..450712d1 100644 --- a/field.go +++ b/field.go @@ -8,7 +8,8 @@ import ( type Field struct { *StructField - Field reflect.Value + IsBlank bool + Field reflect.Value } func (field *Field) Set(value interface{}) (err error) { diff --git a/struct_field.go b/model_struct.go similarity index 91% rename from struct_field.go rename to model_struct.go index 4957dd1d..9f641443 100644 --- a/struct_field.go +++ b/model_struct.go @@ -8,10 +8,15 @@ import ( "time" ) +type ModelStruct struct { + PrimaryKeyField *StructField + StructFields []*StructField + TableName string +} + type StructField struct { Name string DBName string - IsBlank bool IsPrimaryKey bool IsScanner bool IsTime bool @@ -19,7 +24,17 @@ type StructField struct { IsIgnored bool DefaultValue *string SqlTag string - Relationship *relationship + Relationship *Relationship +} + +type Relationship struct { + Kind string + ForeignType string + ForeignFieldName string + ForeignDBName string + AssociationForeignFieldName string + AssociationForeignDBName string + JoinTable string } func (scope *Scope) GetStructFields() (fields []*StructField) { @@ -192,10 +207,8 @@ func (scope *Scope) GetStructFields() (fields []*StructField) { } if field.IsNormal { typ + " " + additionalType - } - } else if !field.IsTime { - return typ + " " + additionalType - } + } else if !field.IsTime { + return typ + " " + additionalType } if len(typ) == 0 {