Fix error 500 on organization dashboard page (#150)

This commit is contained in:
Lunny Xiao 2016-11-12 00:40:21 +08:00 committed by GitHub
parent e2aa991e10
commit a8c6698de8
12 changed files with 190 additions and 162 deletions

View file

@ -5,7 +5,6 @@
package xorm
import (
"errors"
"fmt"
"strconv"
"strings"
@ -258,8 +257,9 @@ func (db *mssql) SqlType(c *core.Column) string {
return core.Int
}
var hasLen1 bool = (c.Length > 0)
var hasLen2 bool = (c.Length2 > 0)
hasLen1 := (c.Length > 0)
hasLen2 := (c.Length2 > 0)
if hasLen2 {
res += "(" + strconv.Itoa(c.Length) + "," + strconv.Itoa(c.Length2) + ")"
} else if hasLen1 {
@ -371,17 +371,16 @@ func (db *mssql) GetColumns(tableName string) ([]string, map[string]*core.Column
}
switch ct {
case "DATETIMEOFFSET":
col.SQLType = core.SQLType{core.TimeStampz, 0, 0}
col.SQLType = core.SQLType{Name: core.TimeStampz, DefaultLength: 0, DefaultLength2: 0}
case "NVARCHAR":
col.SQLType = core.SQLType{core.NVarchar, 0, 0}
col.SQLType = core.SQLType{Name: core.NVarchar, DefaultLength: 0, DefaultLength2: 0}
case "IMAGE":
col.SQLType = core.SQLType{core.VarBinary, 0, 0}
col.SQLType = core.SQLType{Name: core.VarBinary, DefaultLength: 0, DefaultLength2: 0}
default:
if _, ok := core.SqlTypes[ct]; ok {
col.SQLType = core.SQLType{ct, 0, 0}
col.SQLType = core.SQLType{Name: ct, DefaultLength: 0, DefaultLength2: 0}
} else {
return nil, nil, errors.New(fmt.Sprintf("unknow colType %v for %v - %v",
ct, tableName, col.Name))
return nil, nil, fmt.Errorf("Unknown colType %v for %v - %v", ct, tableName, col.Name)
}
}