Optimize maligned structs

This commit is contained in:
Nitin Mohan
2021-03-08 12:44:14 +05:30
parent 7909fb5ff3
commit f554a1c543
12 changed files with 91 additions and 88 deletions

View File

@@ -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 {