Optimize maligned structs
This commit is contained in:
@@ -101,29 +101,30 @@ func newFields() *fields {
|
||||
|
||||
// single field info
|
||||
type fieldInfo struct {
|
||||
mi *modelInfo
|
||||
fieldIndex []int
|
||||
fieldType int
|
||||
dbcol bool // table column fk and onetoone
|
||||
inModel bool
|
||||
name string
|
||||
fullName string
|
||||
column string
|
||||
addrValue reflect.Value
|
||||
sf reflect.StructField
|
||||
auto bool
|
||||
pk bool
|
||||
null bool
|
||||
index bool
|
||||
unique bool
|
||||
colDefault bool // whether has default tag
|
||||
initial StrTo // store the default value
|
||||
size int
|
||||
colDefault bool // whether has default tag
|
||||
toText bool
|
||||
autoNow bool
|
||||
autoNowAdd bool
|
||||
rel bool // if type equal to RelForeignKey, RelOneToOne, RelManyToMany then true
|
||||
reverse bool
|
||||
isFielder bool // implement Fielder interface
|
||||
mi *modelInfo
|
||||
fieldIndex []int
|
||||
fieldType int
|
||||
name string
|
||||
fullName string
|
||||
column string
|
||||
addrValue reflect.Value
|
||||
sf reflect.StructField
|
||||
initial StrTo // store the default value
|
||||
size int
|
||||
reverseField string
|
||||
reverseFieldInfo *fieldInfo
|
||||
reverseFieldInfoTwo *fieldInfo
|
||||
@@ -134,7 +135,6 @@ type fieldInfo struct {
|
||||
relModelInfo *modelInfo
|
||||
digits int
|
||||
decimals int
|
||||
isFielder bool // implement Fielder interface
|
||||
onDelete string
|
||||
description string
|
||||
timePrecision *int
|
||||
|
||||
@@ -22,16 +22,16 @@ import (
|
||||
|
||||
// single model info
|
||||
type modelInfo struct {
|
||||
manual bool
|
||||
isThrough bool
|
||||
pkg string
|
||||
name string
|
||||
fullName string
|
||||
table string
|
||||
model interface{}
|
||||
fields *fields
|
||||
manual bool
|
||||
addrField reflect.Value // store the original struct value
|
||||
uniques []string
|
||||
isThrough bool
|
||||
}
|
||||
|
||||
// new model info
|
||||
|
||||
@@ -118,6 +118,10 @@ var _ Fielder = new(JSONFieldTest)
|
||||
type Data struct {
|
||||
ID int `orm:"column(id)"`
|
||||
Boolean bool
|
||||
Byte byte
|
||||
Int8 int8
|
||||
Uint8 uint8
|
||||
Rune rune
|
||||
Char string `orm:"size(50)"`
|
||||
Text string `orm:"type(text)"`
|
||||
JSON string `orm:"type(json);default({\"name\":\"json\"})"`
|
||||
@@ -125,26 +129,21 @@ type Data struct {
|
||||
Time time.Time `orm:"type(time)"`
|
||||
Date time.Time `orm:"type(date)"`
|
||||
DateTime time.Time `orm:"column(datetime)"`
|
||||
Byte byte
|
||||
Rune rune
|
||||
Int int
|
||||
Int8 int8
|
||||
Uint uint
|
||||
Int16 int16
|
||||
Uint16 uint16
|
||||
Int32 int32
|
||||
Int64 int64
|
||||
Uint uint
|
||||
Uint8 uint8
|
||||
Uint16 uint16
|
||||
Uint32 uint32
|
||||
Uint64 uint64
|
||||
Float32 float32
|
||||
Uint64 uint64
|
||||
Float64 float64
|
||||
Decimal float64 `orm:"digits(8);decimals(4)"`
|
||||
}
|
||||
|
||||
type DataNull struct {
|
||||
ID int `orm:"column(id)"`
|
||||
Boolean bool `orm:"null"`
|
||||
Char string `orm:"null;size(50)"`
|
||||
Text string `orm:"null;type(text)"`
|
||||
JSON string `orm:"type(json);null"`
|
||||
@@ -153,19 +152,20 @@ type DataNull struct {
|
||||
Date time.Time `orm:"null;type(date)"`
|
||||
DateTime time.Time `orm:"null;column(datetime)"`
|
||||
DateTimePrecision time.Time `orm:"null;type(datetime);precision(4)"`
|
||||
Boolean bool `orm:"null"`
|
||||
Byte byte `orm:"null"`
|
||||
Int8 int8 `orm:"null"`
|
||||
Uint8 uint8 `orm:"null"`
|
||||
Rune rune `orm:"null"`
|
||||
Int int `orm:"null"`
|
||||
Int8 int8 `orm:"null"`
|
||||
Uint uint `orm:"null"`
|
||||
Int16 int16 `orm:"null"`
|
||||
Uint16 uint16 `orm:"null"`
|
||||
Int32 int32 `orm:"null"`
|
||||
Int64 int64 `orm:"null"`
|
||||
Uint uint `orm:"null"`
|
||||
Uint8 uint8 `orm:"null"`
|
||||
Uint16 uint16 `orm:"null"`
|
||||
Uint32 uint32 `orm:"null"`
|
||||
Uint64 uint64 `orm:"null"`
|
||||
Float32 float32 `orm:"null"`
|
||||
Uint64 uint64 `orm:"null"`
|
||||
Float64 float64 `orm:"null"`
|
||||
Decimal float64 `orm:"digits(8);decimals(4);null"`
|
||||
NullString sql.NullString `orm:"null"`
|
||||
@@ -215,21 +215,21 @@ type Float64 float64
|
||||
type DataCustom struct {
|
||||
ID int `orm:"column(id)"`
|
||||
Boolean Boolean
|
||||
Byte Byte
|
||||
Int8 Int8
|
||||
Uint8 Uint8
|
||||
Rune Rune
|
||||
Char string `orm:"size(50)"`
|
||||
Text string `orm:"type(text)"`
|
||||
Byte Byte
|
||||
Rune Rune
|
||||
Int Int
|
||||
Int8 Int8
|
||||
Uint Uint
|
||||
Int16 Int16
|
||||
Uint16 Uint16
|
||||
Int32 Int32
|
||||
Int64 Int64
|
||||
Uint Uint
|
||||
Uint8 Uint8
|
||||
Uint16 Uint16
|
||||
Uint32 Uint32
|
||||
Uint64 Uint64
|
||||
Float32 Float32
|
||||
Uint64 Uint64
|
||||
Float64 Float64
|
||||
Decimal Float64 `orm:"digits(8);decimals(4)"`
|
||||
}
|
||||
@@ -278,7 +278,9 @@ type User struct {
|
||||
Password string `orm:"size(100)"`
|
||||
Status int16 `orm:"column(Status)"`
|
||||
IsStaff bool
|
||||
IsActive bool `orm:"default(true)"`
|
||||
IsActive bool `orm:"default(true)"`
|
||||
unexport bool `orm:"-"`
|
||||
unexportBool bool
|
||||
Created time.Time `orm:"auto_now_add;type(date)"`
|
||||
Updated time.Time `orm:"auto_now"`
|
||||
Profile *Profile `orm:"null;rel(one);on_delete(set_null)"`
|
||||
@@ -287,8 +289,6 @@ type User struct {
|
||||
Nums int
|
||||
Langs SliceStringField `orm:"size(100)"`
|
||||
Extra JSONFieldTest `orm:"type(text)"`
|
||||
unexport bool `orm:"-"`
|
||||
unexportBool bool
|
||||
}
|
||||
|
||||
func (u *User) TableIndex() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user