mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 18:30:54 +00:00
orm string type default will use varchar(255)
This commit is contained in:
parent
c81bbf9801
commit
618cbf1e66
@ -206,8 +206,8 @@ checkType:
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
goto end
|
goto end
|
||||||
}
|
}
|
||||||
if fieldType == TypeTextField && size != "" {
|
if fieldType == TypeCharField && tags["type"] == "text" {
|
||||||
fieldType = TypeCharField
|
fieldType = TypeTextField
|
||||||
}
|
}
|
||||||
if fieldType == TypeFloatField && (digits != "" || decimals != "") {
|
if fieldType == TypeFloatField && (digits != "" || decimals != "") {
|
||||||
fieldType = TypeDecimalField
|
fieldType = TypeDecimalField
|
||||||
@ -312,7 +312,7 @@ checkType:
|
|||||||
fi.size = int(v)
|
fi.size = int(v)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = fmt.Errorf("size must be specify")
|
fi.size = 255
|
||||||
}
|
}
|
||||||
case TypeTextField:
|
case TypeTextField:
|
||||||
fi.index = false
|
fi.index = false
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
type Data struct {
|
type Data struct {
|
||||||
Id int
|
Id int
|
||||||
Boolean bool
|
Boolean bool
|
||||||
Char string `orm:size(50)`
|
Char string `orm:"size(50)"`
|
||||||
Text string `orm:"type(text)"`
|
Text string `orm:"type(text)"`
|
||||||
Date time.Time `orm:"type(date)"`
|
Date time.Time `orm:"type(date)"`
|
||||||
DateTime time.Time
|
DateTime time.Time
|
||||||
@ -100,7 +100,7 @@ type Post struct {
|
|||||||
Id int
|
Id int
|
||||||
User *User `orm:"rel(fk)"`
|
User *User `orm:"rel(fk)"`
|
||||||
Title string `orm:"size(60)"`
|
Title string `orm:"size(60)"`
|
||||||
Content string ``
|
Content string `orm:"type(text)"`
|
||||||
Created time.Time `orm:"auto_now_add"`
|
Created time.Time `orm:"auto_now_add"`
|
||||||
Updated time.Time `orm:"auto_now"`
|
Updated time.Time `orm:"auto_now"`
|
||||||
Tags []*Tag `orm:"rel(m2m)"`
|
Tags []*Tag `orm:"rel(m2m)"`
|
||||||
@ -125,7 +125,7 @@ func NewTag() *Tag {
|
|||||||
type Comment struct {
|
type Comment struct {
|
||||||
Id int
|
Id int
|
||||||
Post *Post `orm:"rel(fk)"`
|
Post *Post `orm:"rel(fk)"`
|
||||||
Content string ``
|
Content string `orm:"type(text)"`
|
||||||
Parent *Comment `orm:"null;rel(fk)"`
|
Parent *Comment `orm:"null;rel(fk)"`
|
||||||
Created time.Time `orm:"auto_now_add"`
|
Created time.Time `orm:"auto_now_add"`
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ func getFieldType(val reflect.Value) (ft int, err error) {
|
|||||||
case reflect.Bool:
|
case reflect.Bool:
|
||||||
ft = TypeBooleanField
|
ft = TypeBooleanField
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
ft = TypeTextField
|
ft = TypeCharField
|
||||||
case reflect.Invalid:
|
case reflect.Invalid:
|
||||||
default:
|
default:
|
||||||
if elm.CanInterface() {
|
if elm.CanInterface() {
|
||||||
|
Loading…
Reference in New Issue
Block a user