fix a little bug

This commit is contained in:
Lunny Xiao 2013-06-19 10:07:28 +08:00
parent 9935922176
commit 11843b395f
1 changed files with 9 additions and 3 deletions

View File

@ -177,9 +177,15 @@ func (engine *Engine) MapType(t reflect.Type) *Table {
case k == "text":
col.SQLType = Text
case strings.HasPrefix(k, "int"):
col.SQLType = Int
lens := k[len("int")+1 : len(k)-1]
col.Length, _ = strconv.Atoi(lens)
if k == "int" {
col.SQLType = Int
col.Length = Int.DefaultLength
col.Length2 = Int.DefaultLength2
} else {
col.SQLType = Int
lens := k[len("int")+1 : len(k)-1]
col.Length, _ = strconv.Atoi(lens)
}
case strings.HasPrefix(k, "varchar"):
col.SQLType = Varchar
lens := k[len("varchar")+1 : len(k)-1]