forked from mirror/gorm
update
This commit is contained in:
parent
5d692a6bf2
commit
1726cebc2e
3
field.go
3
field.go
|
@ -8,7 +8,8 @@ import (
|
||||||
|
|
||||||
type Field struct {
|
type Field struct {
|
||||||
*StructField
|
*StructField
|
||||||
Field reflect.Value
|
IsBlank bool
|
||||||
|
Field reflect.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (field *Field) Set(value interface{}) (err error) {
|
func (field *Field) Set(value interface{}) (err error) {
|
||||||
|
|
|
@ -8,10 +8,15 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ModelStruct struct {
|
||||||
|
PrimaryKeyField *StructField
|
||||||
|
StructFields []*StructField
|
||||||
|
TableName string
|
||||||
|
}
|
||||||
|
|
||||||
type StructField struct {
|
type StructField struct {
|
||||||
Name string
|
Name string
|
||||||
DBName string
|
DBName string
|
||||||
IsBlank bool
|
|
||||||
IsPrimaryKey bool
|
IsPrimaryKey bool
|
||||||
IsScanner bool
|
IsScanner bool
|
||||||
IsTime bool
|
IsTime bool
|
||||||
|
@ -19,7 +24,17 @@ type StructField struct {
|
||||||
IsIgnored bool
|
IsIgnored bool
|
||||||
DefaultValue *string
|
DefaultValue *string
|
||||||
SqlTag 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) {
|
func (scope *Scope) GetStructFields() (fields []*StructField) {
|
||||||
|
@ -192,10 +207,8 @@ func (scope *Scope) GetStructFields() (fields []*StructField) {
|
||||||
}
|
}
|
||||||
if field.IsNormal {
|
if field.IsNormal {
|
||||||
typ + " " + additionalType
|
typ + " " + additionalType
|
||||||
}
|
} else if !field.IsTime {
|
||||||
} else if !field.IsTime {
|
return typ + " " + additionalType
|
||||||
return typ + " " + additionalType
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(typ) == 0 {
|
if len(typ) == 0 {
|
Loading…
Reference in New Issue