1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 20:20:55 +00:00

修正当表没有主键时bug

This commit is contained in:
Liujian 2014-10-16 21:36:38 +08:00
parent 40f2451ca4
commit 6c40f1a629

View File

@ -144,19 +144,6 @@ func genHprose(dbms, connStr string, mode byte, selectedTableNames map[string]bo
if trans, ok := dbDriver[dbms]; ok { if trans, ok := dbDriver[dbms]; ok {
ColorLog("[INFO] Analyzing database tables...\n") ColorLog("[INFO] Analyzing database tables...\n")
tableNames := trans.GetTableNames(db) tableNames := trans.GetTableNames(db)
// 添加 Hprose Function
if selectedTableNames == nil {
for _, tb := range tableNames {
hproseAddFunctions = append(hproseAddFunctions, strings.Replace(HPROSE_ADDFUNCTION, "{{modelName}}", camelCase(tb), -1))
}
} else {
for tb, v := range selectedTableNames {
if v {
hproseAddFunctions = append(hproseAddFunctions, strings.Replace(HPROSE_ADDFUNCTION, "{{modelName}}", camelCase(tb), -1))
}
}
}
// 添加结束
tables := getTableObjects(tableNames, db, trans) tables := getTableObjects(tableNames, db, trans)
mvcPath := new(MvcPath) mvcPath := new(MvcPath)
mvcPath.ModelPath = path.Join(currpath, "models") mvcPath.ModelPath = path.Join(currpath, "models")
@ -216,6 +203,7 @@ func writeHproseModelFiles(tables []*Table, mPath string, selectedTables map[str
template = HPROSE_STRUCT_MODEL_TPL template = HPROSE_STRUCT_MODEL_TPL
} else { } else {
template = HPROSE_MODEL_TPL template = HPROSE_MODEL_TPL
hproseAddFunctions = append(hproseAddFunctions, strings.Replace(HPROSE_ADDFUNCTION, "{{modelName}}", camelCase(tb.Name), -1))
} }
fileStr := strings.Replace(template, "{{modelStruct}}", tb.String(), 1) fileStr := strings.Replace(template, "{{modelStruct}}", tb.String(), 1)
fileStr = strings.Replace(fileStr, "{{modelName}}", camelCase(tb.Name), -1) fileStr = strings.Replace(fileStr, "{{modelName}}", camelCase(tb.Name), -1)