Merge branch 'master' into develop

This commit is contained in:
astaxie 2016-04-05 22:27:20 +08:00
commit bccfd667c1
6 changed files with 32 additions and 13 deletions

View File

@ -7,7 +7,7 @@ Bee is a command line tool facilitating development with beego framework.
## Requirements
- Go version >= 1.1.
- Go version >= 1.3.
## Installation

2
fix.go
View File

@ -12,7 +12,7 @@ import (
var cmdFix = &Command{
UsageLine: "fix",
Short: "fix the beego application to compatibel with beego 1.6",
Short: "fix the beego application to make it compatible with beego 1.6",
Long: `
As from beego1.6, there's some incompatible code with the old version.

View File

@ -516,7 +516,9 @@ func (*MysqlDB) GetGoDataType(sqlType string) (goType string) {
func (*PostgresDB) GetTableNames(db *sql.DB) (tables []string) {
rows, err := db.Query(`
SELECT table_name FROM information_schema.tables
WHERE table_catalog = current_database() and table_schema = 'public'`)
WHERE table_catalog = current_database() AND
table_type = 'BASE TABLE' AND
table_schema NOT IN ('pg_catalog', 'information_schema')`)
if err != nil {
ColorLog("[ERRO] Could not show tables: %s\n", err)
ColorLog("[HINT] Check your connection string\n")
@ -551,8 +553,10 @@ func (*PostgresDB) GetConstraints(db *sql.DB, table *Table, blackList map[string
INNER JOIN
information_schema.constraint_column_usage cu ON cu.constraint_name = c.constraint_name
WHERE
c.table_catalog = current_database() AND c.table_schema = 'public' AND c.table_name = $1
AND u.table_catalog = current_database() AND u.table_schema = 'public' AND u.table_name = $2`,
c.table_catalog = current_database() AND c.table_schema NOT IN ('pg_catalog', 'information_schema')
AND c.table_name = $1
AND u.table_catalog = current_database() AND u.table_schema NOT IN ('pg_catalog', 'information_schema')
AND u.table_name = $2`,
table.Name, table.Name) // u.position_in_unique_constraint,
if err != nil {
ColorLog("[ERRO] Could not query INFORMATION_SCHEMA for PK/UK/FK information: %s\n", err)
@ -608,7 +612,8 @@ func (postgresDB *PostgresDB) GetColumns(db *sql.DB, table *Table, blackList map
FROM
information_schema.columns
WHERE
table_catalog = current_database() AND table_schema = 'public' AND table_name = $1`,
table_catalog = current_database() AND table_schema NOT IN ('pg_catalog', 'information_schema')
AND table_name = $1`,
table.Name)
defer colDefRows.Close()
for colDefRows.Next() {
@ -985,12 +990,12 @@ func getPackagePath(curpath string) (packpath string) {
ColorLog("[ERRO] Can't generate application code outside of GOPATH '%s'\n", gopath)
os.Exit(2)
}
if curpath == appsrcpath {
ColorLog("[ERRO] Can't generate application code outside of application PATH \n")
os.Exit(2)
}
packpath = strings.Join(strings.Split(curpath[len(appsrcpath)+1:], string(filepath.Separator)), "/")
return
}

View File

@ -395,10 +395,13 @@ func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpat
tmp = make([]rune, 0)
j += 1
start = false
continue
} else {
st[j] = strings.TrimSpace(ss[i+1:])
break
if j == 1 {
continue
} else {
st[j] = strings.TrimSpace(ss[i+1:])
break
}
}
} else {
start = true

6
run.go
View File

@ -26,7 +26,7 @@ import (
)
var cmdRun = &Command{
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-e=Godeps -e=folderToExclude]",
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-e=Godeps -e=folderToExclude] [-tags=goBuildTags]",
Short: "run the app and start a Web server for development",
Long: `
Run command will supervise the file system of the beego project using inotify,
@ -43,12 +43,16 @@ var gendoc docValue
// The flags list of the paths excluded from watching
var excludedPaths strFlags
// Pass through to -tags arg of "go build"
var buildTags string
func init() {
cmdRun.Run = runApp
cmdRun.Flag.Var(&mainFiles, "main", "specify main go files")
cmdRun.Flag.Var(&gendoc, "gendoc", "auto generate the docs")
cmdRun.Flag.Var(&downdoc, "downdoc", "auto download swagger file when not exist")
cmdRun.Flag.Var(&excludedPaths, "e", "Excluded paths[].")
cmdRun.Flag.StringVar(&buildTags, "tags", "", "Build tags (https://golang.org/pkg/go/build/)")
}
var appname string

View File

@ -136,6 +136,7 @@ func Autobuild(files []string, isgenerate bool) {
icmd := exec.Command("go", "list", "./...")
buf := bytes.NewBuffer([]byte(""))
icmd.Stdout = buf
icmd.Env = append(os.Environ(), "GOGC=off")
err = icmd.Run()
if err == nil {
list := strings.Split(buf.String(), "\n")[1:]
@ -146,6 +147,7 @@ func Autobuild(files []string, isgenerate bool) {
icmd = exec.Command(cmdName, "install", pkg)
icmd.Stdout = os.Stdout
icmd.Stderr = os.Stderr
icmd.Env = append(os.Environ(), "GOGC=off")
err = icmd.Run()
if err != nil {
break
@ -156,6 +158,7 @@ func Autobuild(files []string, isgenerate bool) {
if isgenerate {
icmd := exec.Command("bee", "generate", "docs")
icmd.Env = append(os.Environ(), "GOGC=off")
icmd.Stdout = os.Stdout
icmd.Stderr = os.Stderr
icmd.Run()
@ -170,9 +173,13 @@ func Autobuild(files []string, isgenerate bool) {
args := []string{"build"}
args = append(args, "-o", appName)
if buildTags != "" {
args = append(args, "-tags", buildTags)
}
args = append(args, files...)
bcmd := exec.Command(cmdName, args...)
bcmd.Env = append(os.Environ(), "GOGC=off")
bcmd.Stdout = os.Stdout
bcmd.Stderr = os.Stderr
err = bcmd.Run()