618cbf1e by slene

orm string type default will use varchar(255)

1 parent c81bbf98
...@@ -206,8 +206,8 @@ checkType: ...@@ -206,8 +206,8 @@ checkType:
206 if err != nil { 206 if err != nil {
207 goto end 207 goto end
208 } 208 }
209 if fieldType == TypeTextField && size != "" { 209 if fieldType == TypeCharField && tags["type"] == "text" {
210 fieldType = TypeCharField 210 fieldType = TypeTextField
211 } 211 }
212 if fieldType == TypeFloatField && (digits != "" || decimals != "") { 212 if fieldType == TypeFloatField && (digits != "" || decimals != "") {
213 fieldType = TypeDecimalField 213 fieldType = TypeDecimalField
...@@ -312,7 +312,7 @@ checkType: ...@@ -312,7 +312,7 @@ checkType:
312 fi.size = int(v) 312 fi.size = int(v)
313 } 313 }
314 } else { 314 } else {
315 err = fmt.Errorf("size must be specify") 315 fi.size = 255
316 } 316 }
317 case TypeTextField: 317 case TypeTextField:
318 fi.index = false 318 fi.index = false
......
...@@ -15,7 +15,7 @@ import ( ...@@ -15,7 +15,7 @@ import (
15 type Data struct { 15 type Data struct {
16 Id int 16 Id int
17 Boolean bool 17 Boolean bool
18 Char string `orm:size(50)` 18 Char string `orm:"size(50)"`
19 Text string `orm:"type(text)"` 19 Text string `orm:"type(text)"`
20 Date time.Time `orm:"type(date)"` 20 Date time.Time `orm:"type(date)"`
21 DateTime time.Time 21 DateTime time.Time
...@@ -100,7 +100,7 @@ type Post struct { ...@@ -100,7 +100,7 @@ type Post struct {
100 Id int 100 Id int
101 User *User `orm:"rel(fk)"` 101 User *User `orm:"rel(fk)"`
102 Title string `orm:"size(60)"` 102 Title string `orm:"size(60)"`
103 Content string `` 103 Content string `orm:"type(text)"`
104 Created time.Time `orm:"auto_now_add"` 104 Created time.Time `orm:"auto_now_add"`
105 Updated time.Time `orm:"auto_now"` 105 Updated time.Time `orm:"auto_now"`
106 Tags []*Tag `orm:"rel(m2m)"` 106 Tags []*Tag `orm:"rel(m2m)"`
...@@ -125,7 +125,7 @@ func NewTag() *Tag { ...@@ -125,7 +125,7 @@ func NewTag() *Tag {
125 type Comment struct { 125 type Comment struct {
126 Id int 126 Id int
127 Post *Post `orm:"rel(fk)"` 127 Post *Post `orm:"rel(fk)"`
128 Content string `` 128 Content string `orm:"type(text)"`
129 Parent *Comment `orm:"null;rel(fk)"` 129 Parent *Comment `orm:"null;rel(fk)"`
130 Created time.Time `orm:"auto_now_add"` 130 Created time.Time `orm:"auto_now_add"`
131 } 131 }
......
...@@ -64,7 +64,7 @@ func getFieldType(val reflect.Value) (ft int, err error) { ...@@ -64,7 +64,7 @@ func getFieldType(val reflect.Value) (ft int, err error) {
64 case reflect.Bool: 64 case reflect.Bool:
65 ft = TypeBooleanField 65 ft = TypeBooleanField
66 case reflect.String: 66 case reflect.String:
67 ft = TypeTextField 67 ft = TypeCharField
68 case reflect.Invalid: 68 case reflect.Invalid:
69 default: 69 default:
70 if elm.CanInterface() { 70 if elm.CanInterface() {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!